Created
July 26, 2018 16:41
-
-
Save struppigel/c8fb092622e8c5c869fd18ac5489f8e0 to your computer and use it in GitHub Desktop.
Deobfuscates Batch script in https://www.gdatasoftware.com/blog/2018/07/30924-g-data-analysis-discovers-dosfuscation-in-the-wild
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import re | |
if len(sys.argv) <= 1: exit() | |
scriptpath = sys.argv[1] | |
with open(scriptpath, 'r') as scriptfile: | |
script = scriptfile.read().replace('^', '') | |
p = re.compile('\([Ss][Ee][Tt][^=]+=([^&]+)&&') | |
s = p.search(script) | |
if s != None: | |
alphabet = s.group(1) | |
script = re.sub(r'[,\+;]', '', script) | |
p = re.compile('\(([0-9 ]+)\)') | |
s = p.search(script) | |
if s != None: | |
indices = s.group(1).split() | |
for i in indices: | |
idx = int(i) | |
if idx < len(alphabet): | |
sys.stdout.write(alphabet[idx]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh, my... I just found this today while looking for my own script by the same name. Here is my dynamic take on de-DOSfuscation, if you're interested :)
https://github.com/fireeye/flare-qdb/blob/master/flareqdb/scripts/deDOSfuscator.py
https://www.fireeye.com/blog/threat-research/2018/11/cmd-and-conquer-de-dosfuscation-with-flare-qdb.html