Skip to content

Commit

Permalink
added PDF support
Browse files Browse the repository at this point in the history
  • Loading branch information
vnik committed Sep 15, 2015
1 parent 82eb31e commit c5b8c5e
Show file tree
Hide file tree
Showing 5 changed files with 527 additions and 46 deletions.
21 changes: 1 addition & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Hash Formats

Currently, the following algorithms are supported:

* Password protected PDF files (v1.4 - v1.6)
* NTLM
* MD5
* SHA1
Expand All @@ -32,23 +33,3 @@ Submitting Hashes

Refer to our FAQ for detailed instructions on submitting hashes
(https://hashcrack.org/crackq_faq).

```
$ ./crackqcli.py -h
Crackq client 0.3.1
[email protected]
./crackqcli.py [-t|--type hash_type] [hash|file_path]
-t --type see supported hash types below
-h --help help
Supported hash types:
md5 Unsalted MD5 hashes
ntlm Windows NTLM hashes
sha1 Unsalted SHA1 hashes
wpa WPA/WPA2 handshakes
md5crypt MD5CRYPT / FreeBSD MD5 / Cisco IOS MD5 / MD5(Unix)
descrypt DESCRYPT / DES(Unix)
ike_md5 VPN IPSec IKE (MD5) preshared keys
phpass phpass (Wordpress, Joomla and phpBB3)
```
69 changes: 43 additions & 26 deletions crackqcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import base64
import re
from urllib2 import Request, urlopen, URLError, HTTPError
from thirdparty.termcolor import cprint
from thirdparty.pdf2john import PdfParser

SERVER = 'https://hashcrack.org'
CONFIG_PATH = None
Expand All @@ -19,12 +21,12 @@
'client_ver' : '/crackq/v0.1/client_ver'
}
API_KEY = None
MYVER = '0.3.1'
HASH_TYPES = ['wpa', 'descrypt', 'md5crypt', 'md5', 'ntlm', 'sha1', 'ike_md5', 'phpass']
MYVER = '0.3.2'
HASH_TYPES = ['wpa', 'descrypt', 'md5crypt', 'md5', 'ntlm', 'sha1', 'pdf', 'phpass']

def banner():
sys.stdout.write('Crackq client %s\n' % MYVER)
sys.stdout.write('[email protected]\n\n')
cprint('Crackq client %s' % MYVER, 'green')
cprint('[email protected]\n', 'green')

def usage(argv0):
sys.stdout.write('%s [-t|--type hash_type] [hash|file_path]\n' % argv0)
Expand All @@ -37,7 +39,7 @@ def usage(argv0):
sys.stdout.write('wpa WPA/WPA2 handshakes\n')
sys.stdout.write('md5crypt MD5CRYPT / FreeBSD MD5 / Cisco IOS MD5 / MD5(Unix)\n')
sys.stdout.write('descrypt DESCRYPT / DES(Unix)\n')
sys.stdout.write('ike_md5 VPN IPSec IKE (MD5) preshared keys\n')
sys.stdout.write('pdf PDF 1.4 - 1.6\n')
sys.stdout.write('phpass phpass (Wordpress, Joomla and phpBB3)\n')

def validate_hash(_hash, _hash_type):
Expand Down Expand Up @@ -130,28 +132,29 @@ def load_config():
if o in ('-t', '--type'):
_type = a

# check for updates
if urlopen(SERVER + ENDPOINTS['client_ver']).read() != MYVER:
sys.stdout.write('[-] WARNING: NEW CLIENT VERSION IS AVAILABLE. PLEASE UPDATE.\n')
sys.exit(-1)
try:
# check for updates
sys.stdout.write('[+] Checking the current client version...\n')
if urlopen(SERVER + ENDPOINTS['client_ver']).read() != MYVER:
cprint('[-] WARNING: NEW CLIENT VERSION IS AVAILABLE. PLEASE UPDATE.', 'red')
sys.exit(-1)

if len(args) != 1:
usage(sys.argv[0])
sys.exit(-1)
if len(args) != 1:
usage(sys.argv[0])
sys.exit(-1)

_content = args[0]

if not _type or _type not in HASH_TYPES:
sys.stdout.write('[-] ERROR: INVALID HASH TYPE\n')
sys.exit(-1)
_content = args[0]

if not _type or _type not in HASH_TYPES:
sys.stdout.write('[-] ERROR: INVALID HASH TYPE\n')
sys.exit(-1)

if (_type != 'wpa' and _type != 'pdf') and not validate_hash(_content, _type):
sys.stdout.write('[-] ERROR: INVALID HASH FORMAT\n')
sys.exit(-1)

load_config()

if (_type != 'wpa' and _type != 'ike_md5') and not validate_hash(_content, _type):
sys.stdout.write('[-] ERROR: INVALID HASH FORMAT\n')
sys.exit(-1)

load_config()

try:
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
data = {'key': API_KEY}

Expand All @@ -169,7 +172,7 @@ def load_config():
sys.stdout.write('[-] ERROR: NO QUEUE SUBMISSIONS LEFT. PURCHASE SUBMISSION QUOTA AT https://hashcrack.org/crackq_buy\n')
sys.exit(-1)

if _type == 'wpa' or _type == 'ike_md5':
if _type == 'wpa':
try:
f = open(_content, 'r')
except IOError:
Expand All @@ -183,6 +186,20 @@ def load_config():

_content = base64.b64encode(zlib.compress(_raw))
f.close()

if _type == 'pdf':
parser = PdfParser(_content)

if not parser.supported():
print 'This PDF format is not supported'
sys.exit(-1)
try:
pdf_hash = parser.parse()
except RuntimeError:
e = sys.exc_info()[1]
sys.stderr.write("%s : %s\n" % (filename, str(e)))
sys.exit(-1)
_content = pdf_hash

data = {'key': API_KEY, 'content': _content, 'type': _type, 'q': 'privq'}
req = Request(SERVER + ENDPOINTS['submit'])
Expand All @@ -193,5 +210,5 @@ def load_config():
sys.stdout.write('[-] ERROR: HTTP %d - %s\n' % (e.code, json.load(e)['msg']))
sys.exit(-1)
except URLError as e:
sys.stdout.write('[-] ERROR: UNREACHABLE - %s\n' % e.reason)
cprint('[-] ERROR: UNREACHABLE - %s' % e.reason, 'red')
sys.exit(-1)
Empty file added thirdparty/__init__.py
Empty file.
Loading

0 comments on commit c5b8c5e

Please sign in to comment.