Skip to content

Instantly share code, notes, and snippets.

@BoredHackerBlog
Created July 23, 2022 23:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BoredHackerBlog/8a84be75502193df54e708140380746b to your computer and use it in GitHub Desktop.
Save BoredHackerBlog/8a84be75502193df54e708140380746b to your computer and use it in GitHub Desktop.
Gafgyt/qbot c2 extractor
#Gafgyt/qbot C2 extractor
#https://bazaar.abuse.ch/browse/signature/Gafgyt/
#The file needs to be unpacked (usually packed with upx)
import re
import sys
# regex from https://www.oreilly.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html
ipv4_zero = b"\x00(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?):(\d{0,5})\x00"
ipv4_e9 = b"\xe9(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?):(\d{0,5})\x00"
#requires unpacked file
elffile = open(sys.argv[1], 'rb').read()
re_out = re.search(ipv4_zero, elffile)
if re_out:
print(re_out[0][1:-1].decode('ascii'))
re_out = re.search(ipv4_e9, elffile)
if re_out:
print(re_out[0][1:-1].decode('ascii'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment