Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#Utku Sen
#Divides given string with given block sizes. Might be good for string obfuscation for AV bypass purposes.
#Example:string_divider("[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}",4)
#Output:""+"[Sys"+"tem."+"Net."+"Serv"+"iceP"+"oint"+"Mana"+"ger]"+"::Se"+"rver"+"Cert"+"ific"+"ateV"+"alid"+"atio"+"nCal"+"lbac"+"k = "+"{$tr"+"rue}"+"
def string_divider(string,block_size):
a = ''
str_dict = [ o for o in string ]
parts = [ ''.join( str_dict[ (j * block_size) : ( ( j + 1 ) * block_size ) ] ) for j in xrange(len(string)/block_size )]
parts.append(string[-(len(string)%5):])
parts = ['"'] + parts
for i in parts:
a = a + i+'"+"'
return a
#Converts given string to ASCII values. Might be good for string obfuscation for AV bypass purposes.
#Example: string_to_ascii("example","csharp")
#Output: Convert.ToChar(101)+Convert.ToChar(120)+Convert.ToChar(97)+Convert.ToChar(109)+Convert.ToChar(112)+Convert.ToChar(108)+Convert.ToChar(101)
#Example2: string_to_ascii("example","python")
#Output2: chr(101)+chr(120)+chr(97)+chr(109)+chr(112)+chr(108)+chr(101)
def string_to_ascii(string,lang):
parts = []
a = ''
if lang == "csharp":
for i in string:
parts.append("Convert.ToChar(" + str(ord(i)) + ")")
for i in parts:
a = a + i + '+'
return a
elif lang == "python":
for i in string:
parts.append("chr(" + str(ord(i)) + ")")
for i in parts:
a = a + i + '+'
return a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment