Python

Home / projects / code / Python

Some Python scripts.

John the Ripper Password Guesser

Take the passwords outputted from John the Ripper and try them on a 7zip file. This is an extremely slow way to do this.


"""
Name: John_Runner.py
Description: Simple Python script to take passwords generated by John the Ripper and try them on a 7zip file. 
Usage: john --wordlist=custom_wordlist.lst --rules=Single --stdout | python John_Runner.py > results.txt
"""

from __future__ import print_function
import os
import sys
import subprocess

for line in sys.stdin:
	print("Trying password: ", line)
	password = "-p" + line.strip()
#	File to try cracking
	filename = 'test.7z'
	command = ['7z.exe','x','-y',password,filename]

#	For troubleshooting	
	print(command)

	process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
	for line in process.stdout:
		print(line, end='')
	process.wait()
	print(process.returncode)
	if process.returncode != 2:
		if process.returncode != 7:
			print("*" * 150)
			break
		else:
			print("Fail for some reason")

XOR Rotations

Try every XOR single rotation on a text snippet.


"""
Name: XOR_Rotate.py
Description: Simple Python script to try XOR rotations from 0-255 on a snippet of text. 
Usage: python XOR_Rotate.py
"""

from __future__ import print_function

text_snippet = "This is a test."

for i in range(256):
	print("\nTrying" + hex(i))
	for byte in text_snippet:
		byte = ord(byte)
		byte = byte ^ i
		print('%c' % byte, end='')