Understanding & Detecting C2 Frameworks — HARS (HTTP/S Asynchronous Reverse Shell)

Introduction

HTTP/S Asynchronous Reverse Shell

https://raw.githubusercontent.com/onSec-fr/Http-Asynchronous-Reverse-Shell/master/Images/Concept.png

HARS_Server.py

“__main__”
“InitFile” Function
Example N°1
Example N°2
“start_server” Function
Server: BaseHTTP/0.3 Python/2.7.18
Server: Microsoft-IIS/8.5
“server.pem”
Self-Signed (RED) Vs. Signed (Green)
“MyHandler” Class
“_set_headers” Function
Response from server
Cache-Control: private, max-age=0Content-Type: text/html; charset=utf-8Vary: Accept-EncodingConnection: close
Log file example
“do_GET” Function

Note that the commands / responses sent from the C2 will always be concatenated at the end of the HTML pages. This can be used as an indicator to detect HARS behavior.

“HELLO” Response from the server
“stop_server” Function
Printing results
Web Server “Handler” Logic
Rest of “__main__”

HARS.exe

Default “Error” message
ErrorMsgTitle = "This application could not be started.";ErrorMsgDesc = "Unhandled exception has occured in your application. \r\r Object {0} is not valid.";
“Init” Function
GET /search?q=search+something&qs=n&form=QBRE&cvid=QVMNZNTKDGWBPWARAMXZGWFJTQNUJXYK HTTP/1.1Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8User-Agent: Mozilla/5.0 (compatible, MSIE 11, Windows NT 6.3; Trident/7.0; rv:11.0) like GeckoAccept-Encoding: gzip, deflateCookie: SEVMTE8=Host: 127.0.0.1Connection: close
search?q=search+something&qs=n&form=QBRE&cvid=
GET /search?q=search+something&qs=n&form=QBRE&cvid=IOSAHOBIBKFHYEQUMTGVKSAWXVLXGXUZ HTTP/1.1Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8User-Agent: Mozilla/5.0 (compatible, MSIE 11, Windows NT 6.3; Trident/7.0; rv:11.0) like GeckoAccept-Encoding: gzip, deflateCookie: QVNLHost: 127.0.0.1Connection: close
“ReplyCmd” Function
GET /search?q=search+something&qs=n&form=QBRE&cvid=ZHSKOMDXYBOCTPZPJHTXFUOPJJBAVIAH HTTP/1.1Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8User-Agent: Mozilla/5.0 (compatible, MSIE 11, Windows NT 6.3; Trident/7.0; rv:11.0) like GeckoAccept-Encoding: gzip, deflateCookie: d2luLTYyY3B2NXQ2N2FhNjkxXGMyHost: 127.0.0.1Connection: close
Assembly Information

Conclusion

Indicators

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8User-Agent: Mozilla/5.0 (compatible, MSIE 11, Windows NT 6.3; Trident/7.0; rv:11.0) like GeckoAccept-Encoding: gzip, deflateConnection: close
Server: Microsoft-IIS/8.5Cache-Control: private, max-age=0Content-Type: text/html; charset=utf-8Vary: Accept-EncodingConnection: close
Self-Signed (RED) Vs. Signed (Green)

MITRE ATT&CK

--

--

I write about #Detection #ThreatHunting #WindowsInternals #Malware #DFIR and occasionally #Python.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nasreddine Bencherchali

I write about #Detection #ThreatHunting #WindowsInternals #Malware #DFIR and occasionally #Python.