EvilZone
Programming and Scripting => Scripting Languages => : DeXtreme July 20, 2013, 01:23:27 AM
-
I wrote this script to help me with the Pentesterlab iso so i thought i'd share ;D
It has three functions:a url encoder(for multiple vars),an ascii to unicode convertor and function to split any text(by whitespace or by character) and join them with specified character or text.
For those of you also exploring the Pentesterlab iso,this script helps in the XSS and the SQL injection examples.
Pentesterlab site:https://pentesterlab.com/web_for_pentester.html (https://pentesterlab.com/web_for_pentester.html)
import urllib
#dictionary of commands
cmdic={'u':'unic()','url':'urlenc()','dnc':'dnc()'}
#Functions
def unic():
"""ASCII to UNICODE endcoder(u)"""
string = raw_input("Code:")
#Split string into list of characters
string = list(string)
uni=""
#Convert each character to unicode
for char in string:uni = uni + str(ord(char)) + ","
uni = uni.strip(",")
print uni + "\n"
def urlenc():
"""URL encoder(url)"""
try:
num = raw_input("Number of vars:")
x = 0
varlist = []
while x < int(num):
var = raw_input("Variable:")
val = raw_input("Value:")
#Form list of tuples of vars and values
varlist.append((var,val.decode('string-escape')))
x+=1
#Make dictionary of vars and values
varlist = dict(varlist)
print urllib.urlencode(varlist) + "\n"
except Exception as err:
print "Error:%s\n" %err
def dnc():
"""Divide And Conquer(dnc)-Splits and joins code with given text"""
string = raw_input("Divide:")
sjoin = raw_input("Conquer:")
print "Enter 'w' for whitespace or 'c' for character"
stype = raw_input("By:").lower()
if stype == 'w':
string = string.split()
string = sjoin.join(string)
print string + "\n"
elif stype == 'c':
string = list(string)
string = sjoin.join(string)
print string + "\n"
print "DeX Xware\n"
print "Enter 'l' for a list of available commands\nEnter 'q' to quit\n"
while True:
cmd = raw_input("Command:")
if cmd in cmdic:
exec(cmdic[cmd])
elif cmd.lower() == "q":
break
elif cmd.lower() == "l":
for doc in cmdic.values():
exec("print %s.__doc__" %(doc.replace("()","")))
else:
print "Command not found\n"
-
Great code actually, I don't see anything to pick on, except that you could space out the words and symbols, like:
for char in string:uni=uni+str(ord(char))+","
print uni+"\n"
x+=1
Would make the code more readable.
Also you might want to add more explanation about what it does.
-
I modified your post to add syntax highlighting.
-
Great code actually, I don't see anything to pick on, except that you could space out the words and symbols, like:
for char in string:uni=uni+str(ord(char))+","
print uni+"\n"
x+=1
Would make the code more readable.
Also you might want to add more explanation about what it does.
Thanks Kulver,i sure will.
I modified your post to add syntax highlighting.
Gracias amigo
-
Thanks Kulver,i sure will.
My post might have been confusing, but I meant to say, add spaces between words and symbols.