Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit a38863e

Browse files
author
xajkep
committed
initial commit
0 parents  commit a38863e

File tree

2 files changed

+129
-0
lines changed

2 files changed

+129
-0
lines changed

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# RUDOSH
2+
Reach, Upload, Download with SHortener.
3+
4+
rudosh is a little script to reach the last destination from a shortened URL or to upload/download file using data in shortened URLs.
5+
6+
## Requirements
7+
8+
* Python 2.7
9+
* python-requests
10+
11+
## Notes
12+
13+
* Very slow
14+
* Only for little file
15+
* Made for fun

rudosh.py

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# -*- coding: utf-8 -*-
2+
# xajkep@20161006
3+
import sys, requests, re, base64, math, time
4+
5+
URL = "http://ph.dog"
6+
URL_POST = "http://ph.dog/wp-content/plugins/pretty-link/pro/prlipro-create-public-link.php"
7+
UPLOAD_SIZE = 2**12
8+
9+
print """
10+
_____ _ _ _____ ____ _____ _ _
11+
| __ \| | | | __ \ / __ \ / ____| | | |
12+
| |__) | | | | | | | | | | (___ | |__| |
13+
| _ /| | | | | | | | | |\___ \| __ |
14+
| | \ \| |__| | |__| | |__| |____) | | | |
15+
|_| \_\\_____/|_____/ \____/|_____/|_| |_|
16+
v. 0.1
17+
"""
18+
19+
def reach(url, limit=-1, display=True):
20+
counter = limit
21+
while counter != 0:
22+
try:
23+
if display:
24+
print "[+] Reach %s" % url
25+
r = requests.get(url, allow_redirects=False)
26+
url = r.headers["location"]
27+
return url
28+
except KeyError as e:
29+
if display:
30+
print "[+] Final destination: %s" % r.url
31+
return ""
32+
break
33+
except Exception as e:
34+
print "[-] Error"
35+
print e
36+
exit()
37+
counter -= 1
38+
39+
def init():
40+
r = requests.get("http://ph.dog")
41+
42+
nonce = re.findall("name=\"_wpnonce\" value=\"[a-f0-9]{10}", r.text)[0][-10:]
43+
return (nonce, r.cookies)
44+
45+
46+
def short(destination):
47+
r = requests.get(URL)
48+
nonce, COOKIES = init()
49+
DATA = {
50+
"referral-url": "/",
51+
"redirect_type": -1,
52+
"track": -1,
53+
"group": -1,
54+
"_wpnonce": nonce,
55+
"_wp_http_referer": URL,
56+
"url": destination,
57+
"Submit": "Shrink"
58+
}
59+
60+
r = requests.post(URL_POST, data=DATA, cookies = COOKIES)
61+
return r.url.replace("?slug=", "")
62+
63+
def uploadFile(filename):
64+
data = open(filename, "r").read()
65+
print "[+] File size: %i bytes" % len(data)
66+
b64 = base64.b64encode(data)
67+
print "[+] B64 encoded size: %i bytes" % len(b64)
68+
url = URL
69+
limit = int(math.ceil(len(b64) / float(UPLOAD_SIZE)))
70+
start = time.time()
71+
for i in range(limit):
72+
if i == limit -1:
73+
print "[*] Uploading %i bytes" % (len(b64) % UPLOAD_SIZE)
74+
else:
75+
print "[*] Uploading %i bytes" % UPLOAD_SIZE
76+
url = short(url+"#"+b64[UPLOAD_SIZE*i:UPLOAD_SIZE*(i+1)])
77+
print ""
78+
print "[+] %i bytes uploaded in %i seconds (%i b/s)" % (len(b64), time.time() - start, len(b64)/(time.time() - start))
79+
print "[+] File uploaded: %s" % url
80+
81+
def downloadFile(url, filename):
82+
b64_data = ""
83+
start = time.time()
84+
while 1:
85+
url = reach(url, display=False)
86+
pos = url.find("#")
87+
88+
if pos == -1:
89+
break
90+
91+
pos += 1
92+
93+
print "[+] %i bytes recovered" % len(url[pos:])
94+
b64_data = url[pos:] + b64_data
95+
print "[+] %i bytes downloaded in %i seconds (%i b/s)" % (len(b64_data), time.time() - start, len(b64_data)/(time.time() - start))
96+
data = base64.b64decode(b64_data)
97+
open(filename, "w").write(data)
98+
print "[+] %i bytes written to %s" % (len(data), filename)
99+
100+
101+
102+
if len(sys.argv) == 3 and sys.argv[1] == "-r":
103+
url = sys.argv[2]
104+
while url != "":
105+
url = reach(url)
106+
elif len(sys.argv) == 3 and sys.argv[1] == "-u":
107+
uploadFile(sys.argv[2])
108+
elif len(sys.argv) == 4 and sys.argv[1] == "-d":
109+
downloadFile(sys.argv[2], sys.argv[3])
110+
else:
111+
print "Usage: python rudosh.py -r <url>"
112+
print " python rudosh.py -u <file>"
113+
print " python rudosh.py -d <url> <output>"
114+
exit()

0 commit comments

Comments
 (0)