Commit Diff
Diff:
6468046338fff24d077b691f2e56e1fcbc9c37a4
c1ac38a6cd6f9a06a88f719deb8a66ad0ce20391
Commit:
c1ac38a6cd6f9a06a88f719deb8a66ad0ce20391
Tree:
b43f7bec88bf2f0cf8af3060d5d2c3558a39415d
Author:
jrmu <jrmu@ircnow.org>
Committer:
jrmu <jrmu@ircnow.org>
Date:
Tue Oct 20 07:47:42 2020 UTC
Message:
Refactored Shell, Mail, and BNC
blob - 4900c6bf1ca600ebeea24190b1dcae21366a907d
blob + 64294aa2ce6810d4e4d8ebb4343a662a85215143
--- BNC.pm
+++ BNC.pm
@@ -8,6 +8,7 @@ use OpenBSD::Pledge;
use OpenBSD::Unveil;
use Data::Dumper;
use MIME::Base64;
+use Digest::SHA qw(sha256_hex);
use lib './';
use SQLite;
use Hash;
@@ -23,6 +24,10 @@ my $hostname;
my $terms;
my @logs;
my $time = "600";
+my $sslport;
+my $plainport;
+my $mailfrom;
+my $mailname;
sub init {
$chans = $main::conf{chans};
@@ -33,6 +38,10 @@ sub init {
$znclog = $main::conf{znclog} || "$zncdir/.znc/moddata/adminlog/znc.log";
$hostname = $main::conf{hostname};
$terms = $main::conf{terms};
+ $sslport = $main::conf{sslport};
+ $plainport = $main::conf{plainport};
+ $mailfrom = $main::conf{mailfrom};
+ $mailname = $main::conf{mailname};
#dependencies for figlet
unveil("/usr/local/bin/figlet", "rx") or die "Unable to unveil $!";
unveil("/usr/lib/libc.so.95.1", "r") or die "Unable to unveil $!";
@@ -132,7 +141,7 @@ sub mbnc {
sleep(2);
createbnc($bot, $username, $pass, $bindhost);
main::putserv($bot, "PRIVMSG $nick :Check your email!");
- Mail::mailverify($username, $email, $pass, "bouncer", $version);
+ mailbnc($username, $email, $pass, "bouncer", $version);
#www($newnick, $reply, $password, "bouncer");
} else {
foreach my $chan (@teamchans) {
@@ -299,6 +308,35 @@ EOF
main::putserv($bot, "PRIVMSG *controlpanel :$msg");
return 1;
}
+sub mailbnc {
+ my( $username, $email, $password, $service, $version )=@_;
+ my $passhash = sha256_hex("$username");
+ if ($version =~ /mIRC/) {
+ $version = "mIRC";
+ }
+my $versionhash = encode_base64($version);
+
+my $body = <<"EOF";
+You created a bouncer!
+
+Username: $username
+Password: $password
+Server: $hostname
+Port: $sslport for SSL (secure connection)
+Port: $plainport for plaintext
+
+*IMPORTANT*: Verify your email address:
+
+https://www.$hostname/register.php?id=$passhash&version=$versionhash
+
+You *MUST* click on the link or your account will be deleted.
+
+IRCNow
+EOF
+ Mail::mail($mailfrom, $email, $mailname, "Verify IRCNow Account", $body);
+}
+
+
#if ($hostmask eq '*status!znc@znc.in' && $target =~ /^$nick.?$/) {
# if ($reply eq "You are currently disconnected from IRC. Use 'connect' to reconnect.") {
# if ($verbose >= 3) { print "not connected to $bot->{name}\n"; }
blob - 4c4795b8788aa1fbde7f1f20e76a57d2d19d1640
blob + dac48eecbb00eba2a87fd094d98cf0225f4551f1
--- Mail.pm
+++ Mail.pm
@@ -13,16 +13,12 @@ my $staff;
my $hostname;
my $mailfrom;
my $mailname;
-my $sslport;
-my $plainport;
sub init {
$staff = $main::conf{staff};
$hostname = $main::conf{hostname};
$mailfrom = $main::conf{mailfrom};
$mailname = $main::conf{mailname};
- $sslport = $main::conf{sslport};
- $plainport = $main::conf{plainport};
#dependencies for encrypt
unveil("/usr/bin/encrypt", "rx") or die "Unable to unveil $!";
#dependencies for mail
@@ -63,34 +59,6 @@ close $fh;
return "true";
}
-
-sub mailverify {
- my( $username, $email, $password, $service, $version )=@_;
- my $passhash = sha256_hex("$username");
- if ($version =~ /mIRC/) {
- $version = "mIRC";
- }
-my $versionhash = encode_base64($version);
-
-my $body = <<"EOF";
-You created a bouncer!
-
-Username: $username
-Password: $password
-Server: $hostname
-Port: $sslport for SSL (secure connection)
-Port: $plainport for plaintext
-
-*IMPORTANT*: Verify your email address:
-
-https://www.$hostname/register.php?id=$passhash&version=$versionhash
-
-You *MUST* click on the link or your account will be deleted.
-
-IRCNow
-EOF
- mail($mailfrom, $email, $mailname, "Verify IRCNow Account", $body);
-}
#sub mailfinish {
# my( $username, $password, $email, $service )=@_;
blob - ed6f366022aeb1c64f9d48a3c5155b8b7c66eb47
blob + 4b82720779c42507f34c48bd28e98638330214ac
--- Shell.pm
+++ Shell.pm
@@ -8,6 +8,7 @@ use OpenBSD::Pledge;
use OpenBSD::Unveil;
use MIME::Base64;
use Data::Dumper;
+use Digest::SHA qw(sha256_hex);
use lib './';
use SQLite;
use Hash;
@@ -20,6 +21,8 @@ my $captchaURL = "https://guava.ircnow.org/captcha.php
my $hostname;
my $terms;
my $time = "600";
+my $mailfrom;
+my $mailname;
sub init {
$chans = $main::conf{chans};
@@ -28,6 +31,8 @@ sub init {
$staff = $main::conf{staff};
$hostname = $main::conf{hostname};
$terms = $main::conf{terms};
+ $mailfrom = $main::conf{mailfrom};
+ $mailname = $main::conf{mailname};
#dependencies for figlet
unveil("/usr/local/bin/figlet", "rx") or die "Unable to unveil $!";
unveil("/usr/lib/libc.so.95.1", "r") or die "Unable to unveil $!";
@@ -93,7 +98,7 @@ sub mshell {
sleep(2);
createshell($bot, $username, $pass, $bindhost);
main::putserv($bot, "PRIVMSG $nick :Check your email!");
- Mail::mailverify($username, $email, $pass, "shell", $version);
+ mailshell($username, $email, $pass, "shell", $version);
my $msg = <<"EOF";
Your shell account username is $username and password is $pass . The server is $hostname , port 22. Our official support channel is on #shell. Instructions: https://ircnow.org/kb/doku.php?id=shell:shell .
EOF
@@ -132,6 +137,31 @@ EOF
}
}
}
+sub mailshell {
+ my( $username, $email, $password, $service, $version )=@_;
+ my $passhash = sha256_hex("$username");
+ my $versionhash = encode_base64($version);
+ my $ports;
+ my $body = <<"EOF";
+You created a shell account!
+
+Username: $username
+Password: $password
+Server: $hostname
+SSH Port: 22
+Your Ports: $ports for plaintext
+
+*IMPORTANT*: Verify your email address:
+
+https://www.$hostname/register.php?id=$passhash&version=$versionhash
+
+You *MUST* click on the link or your account will be deleted.
+
+IRCNow
+EOF
+ Mail::mail($mailfrom, $email, $mailname, "Verify IRCNow Account", $body);
+}
+
#sub mregex {
# my ($bot, $nick, $host, $hand, $text) = @_;
blob - /dev/null
blob + c182e29fcc0bb7ec8e313bc89fbc5e7c0f7b447a (mode 644)
--- /dev/null
+++ shell
@@ -0,0 +1,35 @@
+if [ -n "$1" ]; then
+
+groupadd $1
+adduser -batch $1 $1 $1 `encrypt $2`
+
+chmod 700 /home/$1 /home/$1/.ssh
+chmod 600 /home/$1/{.Xdefaults,.cshrc,.cvsrc,.login,.mailrc,.profile}
+mkdir /var/www/htdocs/$1
+ln -s /var/www/htdocs/$1 /home/$1/htdocs
+chown -R $1:www /var/www/htdocs/$1 /home/$1/htdocs
+chmod -R o-rx /var/www/htdocs/$1 /home/$1/htdocs
+chmod -R g+rwx /var/www/htdocs/$1 /home/$1/htdocs
+echo "server \"$1.us10.ircnow.org\" {
+ listen on * tls port 443
+ tls {
+ certificate \"/etc/ssl/$1.us10.ircnow.org.fullchain.pem\"
+ key \"/etc/ssl/private/$1.us10.ircnow.org.key\"
+ }
+ location \"/.well-known/acme-challenge/*\" {
+ root \"/acme\"
+ }
+ location \"*.php\" {
+ fastcgi socket \"/run/php-fpm.sock\"
+ }
+ root \"/htdocs/$1\"
+}
+" >> /etc/httpd.conf
+echo "domain \"$1.us10.ircnow.org\" {
+ domain key \"/etc/ssl/private/$1.us10.ircnow.org.key\"
+ domain full chain certificate \"/etc/ssl/$1.us10.ircnow.org.fullchain.pem\"
+ sign with letsencrypt
+}
+" >> /etc/acme-client.conf
+#edquota $1
+fi