PDA

View Full Version : OKay what is this?


justsexxx
04-06-2002, 03:24 PM
Hi,<br /><br />Got this in my hotmail from an asianaddress or so<br /></font><blockquote><font size="1" face="Verdana, Arial">code:</font><hr /><pre style="font-size:x-small; font-family: fixed;">#!/usr/local/bin/perl <br />$ttsgpath=&quot;/local/wwwcust/karupspc/lcgi-bin/ttsgremoteccbill.pl&quot;; <br />$ttsgserver2 = &quot;bserver.karupspc.com&quot;; <br />chop($date = &amp;ctime(time)); <br /><br />if ($ARGV[0] eq ''){ <br />&amp;Get_Post; <br />$passstring=$date.&quot;!&quot;.join(&quot;|&quot;,@data); <br /># `$ttsgpath -h $ttsgserver2 -p \&quot;$passstring\&quot;`; <br />print &quot;Content-type: text/html\n\n&quot;; <br />} <br />### The Directory secure is designed to be chmod 700 <br />### To keep people out since there is stuff in there <br />### Which hackers should never see. <br /><br />$pwd = '/local/wwwcust/karupspc/ccbill'; <br />$securedir = 'secure'; <br /><br />### Disk Full Hack <br /><br />if($ARGV[0] eq ''){ <br />open(FULL,&quot;&gt;$pwd/$securedir/disk.$$&quot;); <br />print FULL time(); <br />close FULL; <br />open(FULL,&quot;$pwd/$securedir/disk.$$&quot;); <br />$test = &lt;FULL&gt;; <br />close FULL; <br />unlink(&quot;$pwd/$securedir/disk.$$&quot;); <br />if (time()-$test &gt;30){ <br />print &quot;DSK-000&quot;; <br />exit; <br />} <br />} <br /><br />$dmr = 1; <br />$second = 0; <br />$dbm = 1; <br /><br />$second_file = &quot;$pwd/secure/second.txt&quot;; <br /><br />##&amp;Setup; <br /><br />$_ = $ENV{'SERVER_SOFTWARE'}; <br /><br />$nt = 1; <br />if (!/microsoft/i){ <br />$nt = 0; <br />$prog_name = 'ccbill-local.cgi'; <br />} else { <br />$nt_user = $pwd.'/'.$securedir.'/nt_user'; <br />open(NT,$nt_user); <br />$nt_user = ; <br />$nt_user =~ s/\n//g; <br />$nt_user = ', '.$nt_user; <br />$prog_name = 'ccbill-local.pl'; <br />} <br /><br />## Set standard values for locking <br />&amp;lock_values; <br /><br />## Password file with all the members in it. <br />$password_file = &quot;/local/wwwcust/karupspc/dmr/htpasswd&quot;; <br /><br /><br />## Referer file <br />$ref_file = &quot;/var/www/virtual/mesohorny/partners/referer.log&quot;; <br /><br />## Log file of everything that happens <br />$log_file = &quot;$pwd/$securedir/ccbill.log&quot;; <br /><br />## List of current users who are active in the system <br />$current_file = &quot;$pwd/$securedir/current.log&quot;; <br /><br />## Users get move here after they are expired. Reference File <br />$expired_file = &quot;$pwd/$securedir/expired.log&quot;; <br /><br />## Trigger File used for scheduling cleanups <br />$purge_file = &quot;$pwd/$securedir/purge&quot;; <br /><br />## Keyfile contains their assigned system password encrypted <br />## This must match the one on the mysql server <br /><br />$key_file = &quot;$pwd/$securedir/private_key&quot;; <br /><br />## History of additions and deletes <br />$history_file = &quot;&gt;&gt;$pwd/$securedir/history.dat&quot;; <br /><br />## Commissions File <br />$commission = &quot;&gt;&gt;$pwd/$securedir/commission.dat&quot;; <br /><br />$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin'; <br /><br /><br /><br />if ($cmd eq 'Y2K'){ <br />&amp;SQL_Date; <br />} <br /><br /><br />@post_values = split(/:/,$post_values); <br /><br /><br /><br /><br />if ($cmd eq 'CLEANUP'){ <br />&amp;Cleanup; <br />print &quot;CLN-111&quot;; <br />if ($dmr &amp; !$nt){ <br />system(&quot;chmod 666 $password_file&quot;); <br />} <br /><br />exit; <br />} <br /><br /><br /><br />if ($cmd ne '' ){ <br />&amp;Verify_Key; <br />} <br /><br />if ($cmd eq 'ADD'){ <br />&amp;Add_User; <br />&amp;Check_Time; <br />print &quot;ADD-111&quot;; <br />exit; <br />} <br /><br />if ($cmd eq 'KILL'){ <br />&amp;Kill_User; <br />&amp;Check_Time; <br />print &quot;KILL-111&quot;; <br />exit; <br />} <br /><br />if ($cmd eq 'PASS'){ <br />&amp;Check_Password; <br />print &quot;PASS-111&quot;; <br />exit; <br />} <br /><br />open(KEY,$key_file); <br />$key = join('',&lt;KEY&gt;); <br />close KEY; <br /><br />if ($key ne ''){ <br />## System probably working <br />print &quot;111-111&quot;; <br />exit; <br />} else { <br />## System running but not suid or keyfile gone <br />print &quot;101-101&quot;; <br />exit; <br />} <br /><br />exit; <br /><br />sub lock_values <br />{ <br />$LOCK_EX = 2; <br />$LOCK_UN = 8; <br />} <br /><br />sub lock <br />{ <br />local($file) = @_; <br />flock($file,$LOCK_EX); <br /># and, in case someone appended <br /># while we were waiting... <br />seek($file, 0, 2); <br />} <br /><br />sub unlock <br />{ <br />local($file) = @_; <br />flock($file,$LOCK_UN); <br />} <br /><br />sub Verify_Key <br />{ <br /><br />if (!open(KEYFILE,$key_file)){ <br />print &quot;123-000&quot;; <br />exit; <br />} <br /><br />$private_key = &lt;KEYFILE&gt;; <br />$newkey = $private_key; <br />close KEYFILE; <br /><br />$line = $cmd.':'.$verbose.':'.$post_values; <br />@array = split(/:/,$line); <br /><br />foreach $n (@array){ <br />$newkey = crypt($n,reverse($newkey)); <br />} <br /><br />if ($key ne $newkey){ <br />print &quot;999-000&quot;; <br />exit; <br />} <br />} <br /><br />sub Add_User <br />{ <br />### For an adduser command the post values will be of the form <br />### username:password. This means that $post_values[0] is the <br />### username and $post_values[1] is the password. <br />### No you can't add more than one user at a time. <br /><br /><br />### open password file and append <br />if($dbm){ <br />dbmopen(%password,&quot;$password_file&quot;,0666); <br />} else { <br />if(!open(FILE,&quot;&gt;&gt;$password_file&quot;)){ <br />print &quot;ADD-000 $!&quot;; <br />exit; <br />} <br />} <br /><br />if(!$dbm){ <br />print FILE $post_values[0].':'.$post_values[1],&quot;$nt_user\n&quot;; <br />close FILE; <br />} else { <br />### ADD TO DBM FILE HERE <br /><br />$password{$post_values[0]} = $post_values[1]; <br />dbmclose(%password) <br />} <br /><br />### update the log file with whatever is in verbose <br />### but put a header in there for reference <br /><br />if(!open(FILE,&quot;&gt;&gt;$log_file&quot;)){ <br />print &quot;ADD-000&quot;; <br />exit; <br />} <br /><br /><br />&amp;lock('FILE'); <br />print FILE &quot;ADD-$post_values[0]:$post_values[1]|$verbose\n&quot;; <br />&amp;unlock('FILE'); <br /><br />close FILE; <br /><br />### update the current file with whatever is in verbose <br /><br />if (!open(FILE,&quot;&gt;&gt;$current_file&quot;)){ <br />print &quot;ADD-000&quot;; <br />exit; <br />} <br /><br />$_ = $verbose; <br />if (!/:Recurring$/i){ <br />&amp;lock('FILE'); <br />print FILE &quot;$verbose\n&quot;; <br />&amp;unlock('FILE'); <br />} <br /><br />close FILE; <br /><br />($username, $new_subscription_id, $start_date, $end_date, <br />$subscription, $referer, $amount ) = split(/:/,$verbose); <br /><br />if ($referer ne ''){ <br />open(REFERER,&quot;&gt;&gt;$ref_file&quot;); <br />print REFERER &quot;$referer|$amount|$new_subscription_id|$post_value s[0]|$date\n&quot;; <br />close REFERER; <br />} <br /><br />} <br /><br />sub Kill_User <br />{ <br />### For an killuser command the post values will be of the form <br />### username:username:username This means that $post_values[0]...[x] <br />### are the usernames <br />### Multiple Users can be batched for efficiency. <br /><br /><br />if(!$dbm){ <br /><br /><br />### Make a list of who to kill in an associative array <br />@kill = split(/:/,$post_values); <br />foreach $n (@kill){ <br />if ($n ne ''){ <br />$kill{$n} = 1; <br />} <br />} <br /><br />### Open Log File <br />if(!open(LOG,&quot;&gt;&gt;$log_file&quot;)){ <br />print &quot;KILL-002&quot;; <br />exit; <br />} <br /><br />### open password file <br />if(!open(FILE,&quot;$password_file&quot;)){ <br />print &quot;KILL-000&quot;; <br />exit; <br />} <br /><br />$tempfile = $password_file.&quot;$$&quot;; <br />### open temp file to write to <br />if(!open(TEMP,&quot;&gt;$tempfile&quot;)){ <br />print &quot;KILL-001&quot;; <br />exit; <br />} <br /><br />while(&lt;FILE&gt;){ <br />($musr, $mpwd) = split(/:/,$_); <br />if (!$kill{$musr}){ <br />print TEMP $_; <br />} else { <br />&amp;lock('LOG'); <br />print LOG &quot;KILL-$musr\n&quot;; <br />&amp;unlock('LOG'); <br />} <br />} <br /><br />close FILE; <br />close TEMP; <br />close LOG; <br /><br />rename($password_file,&quot;$password_file-bak&quot;); <br />rename($tempfile,$password_file); <br />if ($dmr &amp; !$nt){ <br />system(&quot;chmod 666 $password_file&quot;); <br />} <br /><br /><br />} else { <br /><br />### They're using a DBM file <br /><br />### Open Log File <br />if(!open(LOG,&quot;&gt;&gt;$log_file&quot;)){ <br />print &quot;KILL-002&quot;; <br />exit; <br />} <br /><br />### open password file <br /><br />if(!dbmopen(%password,$password_file,0666)){ <br />print &quot;KILL-000&quot;; <br />exit; <br />} <br /><br /><br />@kill = split(/:/,$post_values); <br />foreach $n (@kill){ <br />if ($n ne ''){ <br />delete($password{&quot;$n&quot;}); <br />} <br />} <br /><br />dbmclose(%password); <br />close LOG; <br /><br />} <br />} <br /><br />sub Cleanup <br />{ <br />### Loop through the current.log file and remove anyone <br />### who is expired. <br /><br />$today = &amp;SQL_Date(time()); <br /><br />open(CURRENT,&quot;$current_file&quot;); <br />while(&lt;CURRENT&gt;){ <br />($username, $sub_id, $start_date, $end_date, $length) = split(/:/,$_); <br />$userdata{$username} = $_; <br />$expires{$username} = $end_date; <br />} <br />close CURRENT; <br /><br />if(!$dbm){ <br /><br />foreach $n (keys %userdata){ <br /><br />if ($expires{$n} &lt; $today){ <br />$kill{$n} = 'YES'; <br /># User has expired. Wipe the userdata clean. <br />$userdata{$n} = ''; <br />} <br />} <br /><br />$tempfile = $current_file.&quot;$$&quot;; <br />open(TEMP,&quot;&gt;$tempfile&quot;); <br />&amp;lock('TEMP'); <br />print TEMP values(%userdata); <br />&amp;unlock('TEMP'); <br />close TEMP; <br /><br />rename($current_file,&quot;$current_file-bak&quot;)

justsexxx
04-06-2002, 03:26 PM
Lol check my status. Unregistred :-) Maybe because it's a long msg?<br /><br />Andre

porntowers.com
04-06-2002, 03:32 PM
Looks like a subscription Perl script since it calls to .htpasswd. Why would anyone send a perl script unsolicited? Odd..<br />Maybe their email list program opened the wrong file to place in their MTA, looks like careless programming.

SexySites
04-06-2002, 07:40 PM
yup looks like perl has messed up alright <img border="0" title="" alt="[Wink]" src="wink.gif" /> <br /><br />laters,<br />Chris