python - While Loops Only Iterates Correctly Once -


i working on python script brute force deobfuscate malicious java script have been finding in security events. long story short @ 1 point in process obfuscating script redirects payload xor. here how going this. python:

#!/usr/bin/python import os import subprocess perl = "perl -pe 's/([;\}\{])/$" userinput = input("") tail = (r"\n/g'") def deobbrute():         count = 0         while (count < 101):                 return(str(userinput)+str(perl)+str(count)+str(tail))                 count = count + 1 output = subprocess.popen(deobbrute(), shell=true).wait results = 0 while (results < 101):         print(output)         results = results + 1 

the user input feeding it:

cat elsepagexoffset |  

elsepagexoffest text file storing obfuscate js in.

it iterates once unless obfuscating xor^1 me no good.

error message other iterations:

<bound method popen.wait of <subprocess.popen object @ 0x7fb65c6c9128>> 

if method (your tabbing messed up), function return (str(userinput)+str(perl)+str(count)+str(tail)) straight away, , rest of function not execute, consider using yield if want continue within method , return more values. yield returns generator, need iterate on deobbrute in order access values

def deobbrute():     count = 0     while (count < 101):         return(str(userinput)+str(perl)+str(count)+str(tail))         count = count + 1  def deobbrute():     count = 0     while (count < 101):         yield(str(userinput)+str(perl)+str(count)+str(tail))         count = count + 1 

try this:

#!/usr/bin/python import os import subprocess perl = "perl -pe 's/([;\}\{])/$" userinput = input("") tail = (r"\n/g'")  def deobbrute():     in range(1, 102):         yield "{0}{1}{2}{3}".format(userinput, perl, i, tail)  brute = deobbrute()  in brute:     print(subprocess.popen(i, shell=true)) 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -