sábado, 27 de janeiro de 2024

Learning Binary Ninja For Reverse Engineering And Scripting

 Recently added a new playlist with about 1.5 hours of Binary Ninja Content so far..   

Video 1: I put this out a couple months ago covering use cases and reversing flows as well as some basic scripting.. 


Videos 2+3 in the playlist start getting specifically into scripting for reversing automation.. Enjoy.. 


@Ficti0n on twitter..   


Video 1 UI Workflows and Scripting:



Video 2: Scripting Part1 


Video 3: Scripting Part 2



Related articles


  1. Hack Tools
  2. Pentest Tools Find Subdomains
  3. Hacker Tools Free Download
  4. Pentest Tools Subdomain
  5. Pentest Tools Url Fuzzer
  6. Pentest Automation Tools
  7. Pentest Tools For Android
  8. Hacker Tools
  9. Hackrf Tools
  10. Kik Hack Tools
  11. Best Pentesting Tools 2018
  12. Hack Tools Mac
  13. Hacker Tools Apk
  14. Pentest Tools List
  15. Hack Tools For Games
  16. Pentest Tools Android
  17. Pentest Tools Website Vulnerability
  18. Hacker Tools
  19. Hacking Tools For Mac
  20. Hacker Tools For Windows
  21. Hacking Tools Mac
  22. Hacking Tools Free Download
  23. Hacker Tools Online
  24. Pentest Tools For Mac
  25. Bluetooth Hacking Tools Kali
  26. Hacker Tools For Mac
  27. Hacker Tools For Ios
  28. Pentest Tools Download
  29. Easy Hack Tools
  30. Hack App
  31. Hack Tools For Pc
  32. Pentest Recon Tools
  33. Pentest Reporting Tools
  34. Hacker Tools List
  35. Pentest Tools Kali Linux
  36. Hack Rom Tools
  37. Hack Tools
  38. Computer Hacker
  39. Hacking Tools For Pc
  40. Best Hacking Tools 2019
  41. Hack Tools
  42. Tools 4 Hack
  43. Hack Tools For Windows
  44. Hacking App
  45. Free Pentest Tools For Windows
  46. Best Pentesting Tools 2018
  47. Pentest Tools Bluekeep
  48. Hack Tools Mac
  49. Hacker Tools For Windows
  50. How To Make Hacking Tools
  51. Hacking App
  52. Game Hacking
  53. Pentest Tools Framework
  54. Hack Tools Download
  55. Pentest Tools For Mac
  56. Black Hat Hacker Tools
  57. Hacking Tools Github
  58. Pentest Tools For Mac
  59. Best Pentesting Tools 2018
  60. Hacker Tools For Windows
  61. Blackhat Hacker Tools
  62. Hacker Tools List
  63. Hacking Tools Download
  64. Hack Tool Apk No Root
  65. Hacker Tools 2019
  66. Pentest Tools For Android
  67. Hacking Tools Mac
  68. Pentest Tools Alternative
  69. Hacking Tools Mac
  70. Github Hacking Tools
  71. Hacker Tools Linux
  72. Pentest Tools Github
  73. Pentest Tools Find Subdomains
  74. Kik Hack Tools
  75. Hacker Tools For Windows
  76. Free Pentest Tools For Windows
  77. Pentest Reporting Tools
  78. Tools 4 Hack
  79. Black Hat Hacker Tools
  80. Top Pentest Tools
  81. Pentest Tools For Windows
  82. Pentest Tools Tcp Port Scanner
  83. Hacking Tools Online
  84. Kik Hack Tools
  85. Hacker Tools For Windows
  86. Pentest Tools Alternative
  87. Hacker Tools Hardware
  88. Pentest Tools For Android
  89. Usb Pentest Tools
  90. Tools 4 Hack
  91. Pentest Tools Url Fuzzer
  92. Tools For Hacker
  93. Underground Hacker Sites
  94. Hacker
  95. Nsa Hack Tools
  96. Pentest Tools Alternative
  97. Hacking App
  98. New Hacker Tools
  99. Kik Hack Tools
  100. Pentest Tools For Mac
  101. Hack Tools For Mac
  102. Hacker Tools For Ios
  103. Black Hat Hacker Tools
  104. Pentest Recon Tools
  105. Hack Tools For Pc
  106. Hacker Tools For Windows
  107. Hacker Tools For Ios
  108. Hack Tools Mac
  109. Hacker Tools For Ios
  110. Hacking Tools Windows 10
  111. Hack Tools Mac
  112. Hacker Tools For Ios
  113. Install Pentest Tools Ubuntu
  114. Hacker Tools 2020
  115. Hack Website Online Tool
  116. Beginner Hacker Tools
  117. World No 1 Hacker Software
  118. Pentest Tools Linux
  119. Hacking Tools For Games
  120. What Are Hacking Tools
  121. Wifi Hacker Tools For Windows
  122. Hacking Tools For Pc
  123. Hacker Tools Online
  124. Hacking Tools
  125. Hack Tools Mac
  126. Hack Tool Apk No Root
  127. Hacking App
  128. Hacking Tools Name
  129. Hacking Tools Software
  130. Hak5 Tools
  131. Hacking Tools For Beginners
  132. Pentest Tools Bluekeep
  133. Nsa Hack Tools
  134. Hackers Toolbox
  135. Hacking Tools For Beginners
  136. Hack Tools Pc
  137. How To Install Pentest Tools In Ubuntu
  138. Hacking Tools Kit
  139. Hacker Security Tools
  140. Kik Hack Tools
  141. Blackhat Hacker Tools
  142. Best Hacking Tools 2020
  143. Hacking Tools And Software
  144. Free Pentest Tools For Windows
  145. Hacking Tools Download
  146. Pentest Recon Tools
  147. Pentest Tools Download
  148. Termux Hacking Tools 2019
  149. Hack Tools For Ubuntu
  150. How To Install Pentest Tools In Ubuntu
  151. Hacking Tools For Kali Linux
  152. How To Hack
  153. Hack App
  154. Beginner Hacker Tools
  155. Hacking Tools
  156. Hacking Tools For Games
  157. Hacking Tools Name
  158. Hacking App
  159. Hacker Hardware Tools
  160. Pentest Tools For Android
  161. Github Hacking Tools
  162. Hack Tools
  163. Hack Tools Mac
  164. What Is Hacking Tools
  165. Hacker Tools Github
  166. Hacker Hardware Tools
  167. Hack Tools Github
  168. Pentest Tools Open Source
  169. Pentest Recon Tools
  170. Hacker Tools 2019

Smuggler - An HTTP Request Smuggling / Desync Testing Tool


An HTTP Request Smuggling / Desync testing tool written in Python 3


IMPORTANT

This tool does not guarantee no false-positives or false-negatives. Just because a mutation may report OK does not mean there isn't a desync issue, but more importantly just because the tool indicates a potential desync issue does not mean there definitely exists one. The script may encounter request processors from large entities (i.e. Google/AWS/Yahoo/Akamai/etc..) that may show false positive results.


Installation

  1. git clone https://github.com/defparam/smuggler.git
  2. cd smuggler
  3. python3 smuggler.py -h

Example Usage

Single Host:

python3 smuggler.py -u <URL>

List of hosts:

cat list_of_hosts.txt | python3 smuggler.py

Options

usage: smuggler.py [-h] [-u URL] [-v VHOST] [-x] [-m METHOD] [-l LOG] [-q]
[-t TIMEOUT] [--no-color] [-c CONFIGFILE]

optional arguments:
-h, --help show this help message and exit
-u URL, --url URL Target URL with Endpoint
-v VHOST, --vhost VHOST
Specify a virtual host
-x, --exit_early Exit scan on first finding
-m METHOD, --method METHOD
HTTP method to use (e.g GET, POST) Default: POST
-l LOG, --log LOG Specify a log file
-q, --quiet Quiet mode will only log issues found
-t TIMEOUT, --timeout TIMEOUT
Socket timeout value Default: 5
--no-color Suppress color codes
-c CONFIGFILE, --configfile CONFIGFILE
Filepath to the configuration file of payloads

Smuggler at a minimum requires either a URL via the -u/--url argument or a list of URLs piped into the script via stdin. If the URL specifies https:// then Smuggler will connect to the host:port using SSL/TLS. If the URL specifies http:// then no SSL/TLS will be used at all. If only the host is specified, then the script will default to https://

Use -v/--vhost <host> to specify a different host header from the server address

Use -x/--exit_early to exit the scan of a given server when a potential issue is found. In piped mode smuggler will just continue to the next host on the list

Use -m/--method <method> to specify a different HTTP verb from POST (i.e GET/PUT/PATCH/OPTIONS/CONNECT/TRACE/DELETE/HEAD/etc...)

Use -l/--log <file> to write output to file as well as stdout

Use -q/--quiet reduce verbosity and only log issues found

Use -t/--timeout <value> to specify the socket timeout. The value should be high enough to conclude that the socket is hanging, but low enough to speed up testing (default: 5)

Use --no-color to suppress the output color codes printed to stdout (logs by default don't include color codes)

Use -c/--configfile <configfile> to specify your smuggler mutation configuration file (default: default.py)


Config Files

Configuration files are python files that exist in the ./config directory of smuggler. These files describe the content of the HTTP requests and the transfer-encoding mutations to test.

Here is example content of default.py:

def render_template(gadget):
RN = "\r\n"
p = Payload()
p.header = "__METHOD__ __ENDPOINT__?cb=__RANDOM__ HTTP/1.1" + RN
# p.header += "Transfer-Encoding: chunked" +RN
p.header += gadget + RN
p.header += "Host: __HOST__" + RN
p.header += "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.87 Safari/537.36" + RN
p.header += "Content-type: application/x-www-form-urlencoded; charset=UTF-8" + RN
p.header += "Content-Length: __REPLACE_CL__" + RN
return p


mutations["nameprefix1"] = render_template(" Transfer-Encoding: chunked")
mutations["tabprefix1"] = render_template("Transfer-Encoding:\tchunked")
mutations["tabprefix2"] = render_template("Transfer-Encoding\t:\tchunked")
mutations["space1"] = render_template("Transfer-Encoding : chunked")

for i in [0x1,0x4,0x8,0x9,0xa,0xb,0xc,0xd,0x1F,0x20,0x7f,0xA0,0xFF]:
mutations["midspace-% 02x"%i] = render_template("Transfer-Encoding:%cchunked"%(i))
mutations["postspace-%02x"%i] = render_template("Transfer-Encoding%c: chunked"%(i))
mutations["prespace-%02x"%i] = render_template("%cTransfer-Encoding: chunked"%(i))
mutations["endspace-%02x"%i] = render_template("Transfer-Encoding: chunked%c"%(i))
mutations["xprespace-%02x"%i] = render_template("X: X%cTransfer-Encoding: chunked"%(i))
mutations["endspacex-%02x"%i] = render_template("Transfer-Encoding: chunked%cX: X"%(i))
mutations["rxprespace-%02x"%i] = render_template("X: X\r%cTransfer-Encoding: chunked"%(i))
mutations["xnprespace-%02x"%i] = render_template("X: X%c\nTransfer-Encoding: chunked"%(i))
mutations["endspacerx-%02x"%i] = render_template("Transfer-Encoding: chunked\r%cX: X"%(i))
mutations["endspacexn-%02x"%i] = render_template("Transfer-Encoding: chunked%c\nX: X"%(i))

There are no input arguments yet on specifying your own customer headers and user-agents. It is recommended to create your own configuration file based on default.py and modify it to your liking.

Smuggler comes with 3 configuration files: default.py (fast), doubles.py (niche, slow), exhaustive.py (very slow) default.py is the fastest because it contains less mutations.

specify configuration files using the -c/--configfile <configfile> command line option


Payloads Directory

Inside the Smuggler directory is the payloads directory. When Smuggler finds a potential CLTE or TECL desync issue, it will automatically dump a binary txt file of the problematic payload in the payloads directory. All payload filenames are annotated with the hostname, desync type and mutation type. Use these payloads to netcat directly to the server or to import into other analysis tools.


Helper Scripts

After you find a desync issue feel free to use my Turbo Intruder desync scripts found Here: https://github.com/defparam/tiscripts DesyncAttack_CLTE.py and DesyncAttack_TECL.py are great scripts to help stage a desync attack


License

These scripts are released under the MIT license. See LICENSE.



Read more
  1. Hacking Tools For Windows 7
  2. Hacking Tools For Games
  3. Hacker Tools Apk Download
  4. Hacker Tools Mac
  5. Pentest Tools Android
  6. Pentest Tools Free
  7. Hak5 Tools
  8. Physical Pentest Tools
  9. How To Hack
  10. Hacker Tools
  11. Pentest Tools Website Vulnerability
  12. Hacking Tools 2020
  13. Hacker Tools Windows
  14. New Hacker Tools
  15. Pentest Tools For Android
  16. How To Hack
  17. Pentest Tools For Windows
  18. Pentest Tools Online
  19. Pentest Tools Website Vulnerability
  20. Pentest Tools Bluekeep
  21. Hack Tools Download
  22. New Hacker Tools
  23. Hak5 Tools
  24. Hack Tools Github
  25. How To Make Hacking Tools
  26. Hacker Tools 2019
  27. Hack Tools For Windows
  28. Pentest Automation Tools
  29. Pentest Tools Windows
  30. Hacker Tools Linux
  31. Hack App
  32. Hack Tool Apk No Root
  33. Hack App
  34. Hacker Tools Apk
  35. Computer Hacker
  36. Hack Apps
  37. Tools 4 Hack
  38. Best Pentesting Tools 2018
  39. Pentest Tools Nmap
  40. Hack Tool Apk
  41. Nsa Hack Tools Download
  42. Kik Hack Tools
  43. What Is Hacking Tools
  44. Pentest Tools For Android
  45. Hacking Tools Windows
  46. What Is Hacking Tools
  47. Pentest Tools For Ubuntu
  48. Nsa Hack Tools
  49. Usb Pentest Tools
  50. Pentest Tools For Android
  51. Pentest Box Tools Download
  52. Hack Tools Download
  53. Hacker Tools Apk Download
  54. Install Pentest Tools Ubuntu
  55. Easy Hack Tools
  56. Pentest Tools Download
  57. Hacking Tools Github
  58. Hack Tools Github
  59. Hacking Tools Windows
  60. Hacking Tools For Pc
  61. How To Hack
  62. Hack Tool Apk
  63. Hack Tools For Windows
  64. Hacking Tools Online
  65. Hacker Tools For Pc
  66. Pentest Tools Apk
  67. Hacker Tools 2019
  68. Best Hacking Tools 2019
  69. Hack Tools For Ubuntu
  70. Hacker Tools 2020
  71. Hack Tools For Games
  72. Hack Tools For Pc
  73. How To Install Pentest Tools In Ubuntu
  74. Hacker Tools
  75. Pentest Reporting Tools
  76. Hacking Tools 2020
  77. Pentest Automation Tools
  78. Pentest Tools For Android
  79. Hacker Tools Github
  80. Pentest Tools
  81. Hacker Security Tools
  82. Hacker Tools Software
  83. Pentest Tools Website
  84. What Is Hacking Tools
  85. Hack App
  86. Pentest Tools Online
  87. Hacker Tools For Pc
  88. Hacker Tools
  89. Pentest Tools Tcp Port Scanner
  90. Hacker Tool Kit
  91. Hacking Tools Pc
  92. Hack Tools For Windows
  93. Hacking App
  94. Hacking Tools For Beginners
  95. Hacking Tools Windows 10
  96. Hacking Tools Mac
  97. New Hacker Tools
  98. Kik Hack Tools
  99. Hak5 Tools
  100. Pentest Tools Tcp Port Scanner
  101. Hack Tools Github
  102. Hack Tools Github
  103. Pentest Tools Linux
  104. Hack Tools Pc
  105. Install Pentest Tools Ubuntu
  106. Hacking Tools Pc
  107. What Is Hacking Tools
  108. Nsa Hack Tools Download
  109. Hack Tools Pc
  110. Wifi Hacker Tools For Windows
  111. Hacking Tools Free Download
  112. Pentest Tools Port Scanner
  113. Hack Tools For Pc
  114. Hacker Tools For Windows
  115. Pentest Tools Find Subdomains
  116. Pentest Reporting Tools
  117. Hacker Tools Online
  118. Pentest Tools For Ubuntu
  119. Pentest Tools Github
  120. Hacker Tools For Mac
  121. Pentest Tools For Android
  122. How To Install Pentest Tools In Ubuntu
  123. Bluetooth Hacking Tools Kali
  124. Pentest Tools Online
  125. Hack Tool Apk No Root
  126. Hacker Tools Apk Download
  127. Ethical Hacker Tools
  128. Pentest Tools For Mac
  129. How To Make Hacking Tools
  130. Pentest Tools Review
  131. Pentest Tools For Windows
  132. Hacker Tools 2020
  133. Hack Tools For Mac
  134. Tools 4 Hack
  135. Hack Tools
  136. Bluetooth Hacking Tools Kali
  137. Hack Tool Apk
  138. Hacker Tools Software
  139. Pentest Tools Windows
  140. Hacker Tools Software
  141. Top Pentest Tools
  142. Hack Rom Tools
  143. Hak5 Tools
  144. Hacker Search Tools
  145. What Are Hacking Tools
  146. Hack Tools For Pc
  147. Free Pentest Tools For Windows
  148. Hacking Tools For Games

Reversing C++ String And QString

After the rust string overview of its internal substructures, let's see if c++ QString storage is more light, but first we'r going to take a look to the c++ standard string object:



At first sight we can see the allocation and deallocation created by the clang++ compiler, and the DAT_00400d34 is the string.

If we use same algorithm than the rust code but in c++:



We have a different decompilation layout. Note that the Ghidra scans very fast the c++ binaries, and with rust binaries gets crazy for a while.
Locating main is also very simple in a c++ compiled binary, indeed is more  low-level than rust.


The byte array is initialized with a simply move instruction:
        00400c4b 48 b8 68        MOV        RAX,0x6f77206f6c6c6568

And basic_string generates the string, in the case of rust this was carazy endless set of calls, detected by ghidra as a runtime, but nevertheless the basic_string is an external imported function not included on the binary.

(gdb) x/x 0x7fffffffe1d0
0x7fffffffe1d0: 0xffffe1e0            low str ptr
0x7fffffffe1d4: 0x00007fff           hight str ptr
0x7fffffffe1d8: 0x0000000b        sz
0x7fffffffe1dc: 0x00000000
0x7fffffffe1e0: 0x6c6c6568         "hello world"
0x7fffffffe1e4: 0x6f77206f
0x7fffffffe1e8: 0x00646c72
0x7fffffffe1ec: 0x00000000        null terminated
(gdb) x/s 0x7fffffffe1e0
0x7fffffffe1e0: "hello world"

The string is on the stack, and it's very curious to see what happens if there are two followed strings like these:

  auto s = string(cstr);
  string s2 = "test";

Clang puts toguether both stack strings:
[ptr1][sz1][string1][null][string2][null][ptr2][sz2]

C++ QString datatype

Let's see the great and featured QString object defined on qstring.cpp and qstring.h

Some QString methods use the QCharRef class whose definition is below:

class Q_EXPORT QCharRef {     friend class QString;     QString& s;     uint p;
 
 Searching for the properties on the QString class I've realized that one improvement that  rust and golang does is the separation from properties and methods, so in the large QString class the methods are  hidden among the hundreds of methods, but basically the storage is a QStringData *;

After removing the methods of QStringData class definition we have this:

struct Q_EXPORT QStringData : public QShared {
    QChar *unicode;
    char *ascii;
#ifdef Q_OS_MAC9
    uint len;
#else
    uint len : 30;

sexta-feira, 26 de janeiro de 2024

Attacking Financial Malware Botnet Panels - SpyEye

This is the second blog post in the "Attacking financial malware botnet panels" series. After playing with Zeus, my attention turned to another old (and dead) botnet, SpyEye. From an ITSEC perspective, SpyEye shares a lot of vulnerabilities with Zeus. 

The following report is based on SpyEye 1.3.45, which is old, and if we are lucky, the whole SpyEye branch will be dead soon. 

Google dorks to find SpyEye C&C server panel related stuff:

  • if the img directory gets indexed, it is rather easy, search for e.g. inurl:b-ftpbackconnect.png
  • if the install directory gets indexed, again, easy, search for e.g. inurl:spylogo.png
  • also, if you find a login screen, check the css file (style.css), and you see #frm_viewlogs, #frm_stat, #frm_botsmon_country, #frm_botstat, #frm_gtaskloader and stuff like that, you can be sure you found it
  • otherwise, it is the best not to Google for it, but get a SpyEye sample and analyze it
And this is how the control panel login looks like, nothing sophisticated:


The best part is that you don't have to guess the admin's username ;)

This is how an average control panel looks like:


Hack the Planet! :)

Boring vulns found (warning, an almost exact copy from the Zeus blog post)


  • Clear text HTTP login - you can sniff the login password via MiTM, or steal the session cookies
  • No password policy - admins can set up really weak passwords
  • No anti brute-force - you can try to guess the admin's password. There is no default username, as there is no username handling!
  • Password autocomplete enabled - boring
  • Missing HttpOnly flag on session cookie - interesting when combining with XSS
  • No CSRF protection - e.g. you can upload new exe, bin files, turn plugins on/off :-( boring. Also the file extension check can be bypassed, but the files are stored in the database, so no PHP shell this time. If you check the following code, you can see that even the file extension and type is checked, and an error is shown, but the upload process continues. And even if the error would stop the upload process, the check can be fooled by setting an invalid $uptype. Well done ...
        if ($_FILES['file']['tmp_name'] && ($_FILES['file']['size'] > 0))         {                 $outstr = "<br>";                 set_time_limit(0);                 $filename = str_replace(" ","_",$_FILES['file']['name']);                 $ext = substr($filename, strrpos($filename, '.')+1);                 if( $ext==='bin' && $uptype!=='config' ) $outstr .= "<font class='error'>Bad CONFIG extension!</font><br>";                 if( $ext==='exe' && $uptype!=='body' && $uptype!=='exe' ) $outstr .= "<font class='error'>Bad extension!</font><br>";                  switch( $uptype )                 {                 case 'body': $ext = 'b'; break;                 case 'config': $ext = 'c'; break;                 case 'exe': $ext = 'e'; break;                 default: $ext = 'e';                 }                 $_SESSION['file_ext'] = $ext;                 if( isset($_POST['bots']) && trim($_POST['bots']) !== '')                 {                         $bots = explode(' ', trim($_POST['bots']));                         //writelog("debug.log", trim($_POST['bots']));                         $filename .= "_".(LastFileId()+1);                 }                 if( FileExist($filename) ) $filename .= LastFileId();                 $tmpName  = $_FILES['file']['tmp_name'];                 $fileSize = $_FILES['file']['size'];                 $fileType = $_FILES['file']['type'];                 ## reading all file for calculating hash                 $fp = fopen($tmpName, 'r'); 
  • Clear text password storage - the MySQL passwords are stored in php files, in clear text. Also, the login password to the form panel is stored in clear text.
  • MD5 password - the passwords stored in MySQL are MD5 passwords. No PBKDF2, bcrypt, scrypt, salt, whatever. MD5. Just look at the pure simplicity of the login check, great work!
$query = "SELECT * FROM users_t WHERE uPswd='".md5($pswd)."'";
  • ClickJacking - really boring stuff

SQL injection


SpyEye has a fancy history of SQL injections. See details here, here, here, video here and video here.

It is important to highlight the fact that most of the vulnerable functions are reachable without any authentication, because these PHP files lack user authentication at the beginning of the files.

But if a C&C server owner gets pwned through this vuln, it is not a good idea to complain to the developer, because after careful reading of the install guide, one can see:

"For searching info in the collector database there is a PHP interface as formgrabber admin panel. The admin panel is not intended to be found on the server. This is a client application."

And there are plenty of reasons not to install the formgrabber admin panel on any internet reachable server. But this fact leads to another possible vulnerability. The user for this control panel is allowed to remotely login to the MySQL database, and the install guide has pretty good passwords to be reused. I mean it looks pretty secure, there is no reason not to use that.

CREATE USER 'frmcpviewer' IDENTIFIED BY 'SgFGSADGFJSDGKFy2763272qffffHDSJ'; 

Next time you find a SpyEye panel, and you can connect to the MySQL database, it is worth a shot to try this password.

Unfortunately the default permissions for this user is not enough to write files (select into outfile):

Access denied for user 'frmcpviewer' (using password: YES)

I also made a little experiment with this SQL injection vulnerability. I did set up a live SpyEye botnet panel, created the malware install binaries (droppers), and sent the droppers to the AV companies. And after more and more sandboxes connected to my box, someone started to exploit the SQL injection vulnerability on my server!

63.217.168.90 - - [16/Jun/2014:04:43:00 -0500] "GET /form/frm_boa-grabber_sub.php?bot_guid=&lm=3&dt=%20where%201=2%20union%20select%20@a:=1%20from%20rep1%20where%20@a%20is%20null%20union%20select%20@a:=%20@a%20%2b1%20union%20select%20concat(id,char(1,3,3,7),bot_guid,char(1,3,3,7),process_name,char(1,3,3,7),hooked_func,char(1,3,3,7),url,char(1,3,3,7),func_data)%20from%20rep2_20140610%20where%20@a=3%23 HTTP/1.1" 200 508 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)"

Although the query did not return any meaningful data to the attacker (only data collected from sandboxes), it raises some legal questions.

Which company/organization has the right to attack my server? 
  • police (having a warrant)
  • military (if we are at war)
  • spy agencies (always/never, choose your favorite answer)
  • CERT organisations?

But, does an AV company or security research company has the legal right to attack my server? I don't think so... The most problematic part is when they hack a server (without authorization), and sell the stolen information in the name of "intelligence service". What is it, the wild wild west?

The SQLi clearly targets the content of the stolen login credentials. If this is not an AV company, but an attacker, how did they got the SpyEye dropper? If this is an AV company, why are they stealing the stolen credentials? Will they notify the internet banking owners about the stolen credentials for free? Or will they do this for money?

And don't get me wrong, I don't want to protect the criminals, but this is clearly a grey area in the law. From an ethical point of view, I agree with hacking the criminal's servers. As you can see, the whole post is about disclosing vulns in these botnet panels. But from a legal point of view, this is something tricky ... I'm really interested in the opinion of others, so comments are warmly welcome.

On a side note, I was interested how did the "attackers" found the SpyEye form directory? Easy, they brute-forced it, with a wordlist having ~43.000 entries.

(Useless) Cross site scripting


Although parts of the SpyEye panel are vulnerable to XSS, it is unlikely that you will to find these components on the server, as these codes are part of the install process, and the installer fails to run if a valid install is found. And in this case, you also need the DB password to trigger the vuln...



Session handling


This is a fun part. The logout button invalidates the session only on the server side, but not on the client side. But if you take into consideration that the login process never regenerates the session cookies (a.k.a session fixation), you can see that no matter how many times the admin logs into the application, the session cookie remains the same (until the admin does not close the browser). So if you find a session cookie which was valid in the past, but is not working at the moment, it is possible that this cookie will be valid in the future ...

Binary server


Some parts of the SpyEye server involve running a binary server component on the server, to collect the form data. It would be interesting to fuzz this component (called sec) for vulns.

Log files revealed


If the form panel mentioned in the SQLi part is installed on the server, it is worth visiting the <form_dir>/logs/error.log file, you might see the path of the webroot folder, IP addresses of the admins, etc.

Reading the code


Sometimes reading the code you can find code snippets, which is hard to understand with a clear mind:

$content = fread($fp, filesize($tmpName)); if ( $uptype === 'config' )     $md5 = GetCRC32($content); else $md5 = md5($content); .... <script> if (navigator.userAgent.indexOf("Mozilla/4.0") != -1) {         alert("Your browser is not support yet. Please, use another (FireFox, Opera, Safari)");         document.getElementById("div_main").innerHTML = "<font class=\'error\'>ChAnGE YOuR BRoWsEr! Dont use BUGGED Microsoft products!</font>"; } </script> 

Decrypting SpyEye communication

It turned out that the communication between the malware and C&C server is not very sophisticated (Zeus does a better job at it, because the RC4 key stream is generated from the botnet password).

function DeCode($content) {         $res = '';         for($i = 0; $i < strlen($content); $i++)         {                 $num = ord($content[$i]);                 if( $num != 219) $res .= chr($num^219);         }         return $res; } 
Fixed XOR key, again, well done ...
This means that it is easy to create a script, which can communicate with the SpyEye server. For example this can be used to fill in the SpyEye database with crap data.


import binascii import requests import httplib, urllib  def xor_str(a, b):     i = 0     xorred = ''     for i in range(len(a)):         xorred += chr(ord(a[i])^b)     return xorred              b64_data= "vK6yv+bt9er17O3r6vqPnoiPjZb2i5j6muvo6+rjmJ/9rb6p5urr6O/j/bK+5uP16/Xs7evq9ers7urv/bSo5u316vXs7evq/a6v5pq/trK1/bi4qbjm453j6uPv7Or9tr/u5um+uuvpve3p7eq/4+vsveLi7Lnqvrjr6ujs7rjt7rns/au3vOa5sre3srW8s7q2tr6p4Lm3tLiw4LmuvKm+q7Spr+C4uPu8qbq5ub6p4Li4vKm6ubm+qeC4qb6/sq+8qbq54LiuqK+0tri0tbW+uK+0qeC/v7So4L+1qLqrsuC+trqyt7ypurm5vqngvb24vqmvvKm6ubm+qeC9/aivuq/mtLW3srW+" payload =xor_str (binascii.a2b_base64(b64_data), 219)  print ("the decrypted payload is: " + payload) params = (binascii.b2a_base64(xor_str(payload,219))) payload = {'data': params} r = requests.post("http://spyeye.localhost/spyeye/_cg/gate.php", data=payload) 

Morale of the story?


Criminals produce the same shitty code as the rest of the world, and thanks to this, some of the malware operators get caught and are behind bars now. And the law is behind the reality, as always.

Read more