Skip to content

Instantly share code, notes, and snippets.

@rostok
Created September 23, 2019 22:01
Show Gist options
  • Save rostok/b33dfc0805c156ddd79dc6c417674d18 to your computer and use it in GitHub Desktop.
Save rostok/b33dfc0805c156ddd79dc6c417674d18 to your computer and use it in GitHub Desktop.
poprawiony lekko skrypt do kradzieży napisow
#!/usr/bin/python
# script downloads subtitles from napiprojekt
#
# reversed napi 0.16.3.1
#
# by gim,krzynio,dosiu,hash 2oo8.
# last modified: 6-I-2oo8
# 4pc0h f0rc3
#
# 20190923 rostok
#
# do dzialania potrzebny jest p7zip-full (tak sie nazywa paczka w debianie)
import md5,sys,urllib,os
def f(z):
idx = [ 0xe, 0x3, 0x6, 0x8, 0x2 ]
mul = [ 2, 2, 5, 4, 3 ]
add = [ 0, 0xd, 0x10, 0xb, 0x5 ]
b = []
for i in xrange(len(idx)):
a = add[i]
m = mul[i]
i = idx[i]
t = a + int(z[i], 16)
v = int(z[t:t+2], 16)
b.append( ("%x" % (v*m))[-1] )
return ''.join(b)
if(len(sys.argv)==1):
print("podaj hash napisow, albo link napiprojekt:XXXXX albo adres strony https://www.napiprojekt.pl/napisy...")
sys.exit(2)
def downnap(d,out=""):
#d = md5.new();
#d.update(open(sys.argv[1]).read(10485760))
#d=sys.argv[1]
d=d.replace("napiprojekt:", "")
str = "http://napiprojekt.pl/unit_napisy/dl.php?l=PL&f="+d+"&t="+f(d)+"&v=other&kolejka=false&nick=&pass=&napios="+os.name
print(str)
arch=d+".7z"
open(arch,"wb").write(urllib.urlopen(str).read())
if out!="":
out=out.strip()+" "
nazwa=out+d+'.txt'
nazwa = nazwa.replace(":","-");
nazwa = nazwa.replace("\\","-");
nazwa = nazwa.replace("/","-");
nazwa = nazwa.replace("?","-");
nazwa = nazwa.replace("\"","");
print(nazwa)
#if (os.system("7z x -y -so -piBlm8NTigvru0Jr0 napisy.7z 2>/dev/null >\""+nazwa+"\"")):
if (os.system("7z x -y -so -piBlm8NTigvru0Jr0 "+arch+" > \""+nazwa+"\"")):
print("nie ma napisa do filmu")
#os.remove(nazwa)
else:
print("napisy pobrano, milordzie!")
os.remove(arch)
return
def dispatch(a):
if a.startswith('http'):
import urllib2
req = urllib2.Request(a)
req.add_header('User-Agent', 'Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0')
p = urllib2.urlopen(req).read()
#open("temp.html","wb").write(p)
#p = urllib.urlopen(a, headers).read()
import re
p = re.findall(r'napiprojekt:(.*?)\<', p)
for x in p:
s=x.split('">')
print(s[0],s[1])
downnap(s[0],s[1])
else:
downnap(a)
return
for x in sys.argv[1:]:
x = x.decode('cp1250').encode('utf-8')
x = urllib.quote(x)
x = x.replace("https%3A//", "https://")
x = x.replace("http%3A//", "http://")
print(x)
dispatch(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment