4 changed files with 105 additions and 0 deletions
@ -1,2 +1,15 @@ |
|||
# easyscripts |
|||
Bunch of scripts that make life easier on command line |
|||
|
|||
Author: Samuel Pua (kahkin@gmail.com) |
|||
|
|||
##Current Scripts Available |
|||
- urlencode.py |
|||
> Encodes strings into urlencoding |
|||
|
|||
- urldecode.py |
|||
> Decodes url encoding back to ascii |
|||
|
|||
##Todos |
|||
- Tab completion |
|||
> Seriously out of my league for now. Easy to way to it seems to be using external library argcomplete. But I prefer not to use external libraries |
|||
|
@ -0,0 +1,5 @@ |
|||
echo "Copying urlencode.py..." |
|||
sudo cp ./urlencode/urlencode.py /usr/bin/ |
|||
|
|||
echo "Copying urldecode.py..." |
|||
sudo cp ./urldecode/urldecode.py /usr/bin/ |
@ -0,0 +1,40 @@ |
|||
#!/usr/bin/env python3 |
|||
# |
|||
# Script to URL encode on CLI |
|||
# Author: Samuel Pua (samuel.pua@mwrinfosecurity.com) |
|||
|
|||
import urllib.parse |
|||
import sys |
|||
|
|||
if ("--help" in sys.argv) or ("-h" in sys.argv) or ("-?" in sys.argv): |
|||
print("URL Decoder") |
|||
print("Author: Samuel Pua\n") |
|||
print("Usage:") |
|||
print("[1] Pipe input into file") |
|||
print() |
|||
print("Flags:") |
|||
print("--help : Prints this help page") |
|||
print("--persistent: Persistent url encoding") |
|||
elif ("--persistent" in sys.argv): |
|||
print("You're in persistent mode. Press Control-C to exit once you're done.\n") |
|||
while True: |
|||
try: |
|||
before=input() |
|||
except KeyboardInterrupt: |
|||
print("Program exiting...") |
|||
sys.exit(0) |
|||
after=before |
|||
after=after.replace("+"," ") |
|||
after=urllib.parse.unquote(after) |
|||
print(after) |
|||
print() |
|||
else: |
|||
before=sys.stdin.read() |
|||
|
|||
beforeList=before.split("\n") |
|||
for before in beforeList: |
|||
after=before |
|||
after=after.replace("+"," ") |
|||
after=urllib.parse.unquote(after) |
|||
print(after) |
|||
|
@ -0,0 +1,47 @@ |
|||
#!/usr/bin/env python3 |
|||
# |
|||
# Script to URL encode on CLI |
|||
# Author: Samuel Pua (samuel.pua@mwrinfosecurity.com) |
|||
|
|||
import urllib.parse |
|||
import sys |
|||
|
|||
if ("--help" in sys.argv) or ("-h" in sys.argv) or ("-?" in sys.argv): |
|||
print("URL Encoder") |
|||
print("Author: Samuel Pua\n") |
|||
print("Usage:") |
|||
print("[1] Pipe input into file") |
|||
print() |
|||
print("Flags:") |
|||
print("--help : Prints this help page") |
|||
print("--ignore-newline: Ignores newline while processing as a single request") |
|||
print("--enforce-newline: Generates url code for newline instead of treating as seperate requests") |
|||
print("--persistent: Persistent url encoding") |
|||
elif ("--persistent" in sys.argv): |
|||
print("You're in persistent mode. Press Control-C to exit once you're done.\n") |
|||
while True: |
|||
try: |
|||
before=input() |
|||
except KeyboardInterrupt: |
|||
print("Program exiting...") |
|||
sys.exit(0) |
|||
after=urllib.parse.urlencode({'str':before}) |
|||
after=after[4:] |
|||
print(after) |
|||
print() |
|||
else: |
|||
before=sys.stdin.read() |
|||
if ("--ignore-newline" in sys.argv): |
|||
before=before.replace("\r\n", "") |
|||
before=before.replace("\n", "") |
|||
beforeList=[before] |
|||
elif ("--enforce-newline" in sys.argv): |
|||
beforeList=[before] |
|||
else: |
|||
beforeList=before.split("\n") |
|||
|
|||
for before in beforeList: |
|||
after=urllib.parse.urlencode({'str':before}) |
|||
after=after[4:] |
|||
print(after) |
|||
|
Loading…
Reference in new issue