Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from bs4 import BeautifulSoup
- from os import walk
- def main():
- thread="http://lupchan.org/b/res/535.html"
- directory = r"C:\Users\usernamegoeshere\Desktop\dump"
- args=read_fields(thread)
- print "Thread page read"
- c=0
- for file in walk(directory).next()[2]:
- upload_file(directory+'\\'+file, args)
- c += 1
- if c>=10: #get again
- args = read_fields(thread)
- c = 0
- def upload_file(nom, args):
- args["name"]="Furfriend"
- args["password"]="12345678"
- args["subject"]="Testan"
- args["email"]=""
- args["body"]="Testing, testing, do you read me?"
- args["embed"]=""
- #args["spoiler"]="on"
- f = {'file': open(nom, 'rb')}
- response = requests.post("http://lupchan.org/post.php", data=args, files=f) #does this go like this? No idea, requests has no proper documentation, but wireshark seems to confirm it works
- print response.content #"Error: you didn't make a post ha ha fuck you"
- def read_fields(thread):
- """Gets a website, returns a dict with all inputs and textareas in the first <form>, just like they'd be sent if you submitted it:
- <input name="thread" value="8848" type="text">
- <textarea name="search" style="display:none">1234qwertyuiop</textarea>
- returns {"thread":"8848", "search":"1234qwertyuiop"}
- """
- r = {}
- t=requests.get(thread).text
- doc = BeautifulSoup(t)
- for input in doc.form.find_all("input"):
- if not input['type'] in ("text", "hidden", "password"):
- continue
- print "OK"
- assert input['name'] not in r
- if input.has_attr('value'):
- r[input['name']] = input['value']
- else:
- r[input['name']] = ""
- for textarea in doc.form.find_all("textarea"):
- if textarea.string: #actually a <class 'bs4.element.NavigableString'>
- r[textarea['name']] = unicode(textarea.string)
- else: # textarea.string == None
- r[textarea['name']] = ""
- return r
- main()
- """
- Important values:
- "thread"="1234" (no need to change)
- "board"="s4s" (no need to change)
- "name" =[name]
- "email"=[email]
- "subject"=[subject]
- "spoiler" (checkbox, "on" or nothing)
- "body"=[text] (textarea)
- "file"=[file] (type=file)
- "embed"=[embed]
- "password"=[password]
- <form name="post" onsubmit="return dopost(this);" enctype="multipart/form-data" action="/post.php" method="post">
- <input type="hidden" name="thread" value="8848">
- <input type="text" name="firstname" value="">
- <input type="hidden" name="board" value="s4s">
- <input style="display:none" type="text" name="url" value="">
- <textarea name="search" style="display:none">'W<JxUo+ENq QX\@>w,D;O[u0c*(S.^YHpvBT3/t6hMKd29$P:=%|L?~rkeCimA-yb5lgsZa4I1n_&#7G]F!{)z8</textarea>
- <input type="text" name="name" size="25" maxlength="35" autocomplete="off">
- <input type="text" name="message" value="N}K,{=:AbHr0V#mv5o9F3;e^+Mfh>Z_).~L681]iks%q|WET$Rp&[2@-4BwO7GudCxPSt">
- <input style="display:none" type="text" name="text" value="">
- <input type="text" name="email" size="25" maxlength="40" autocomplete="off">
- <input style="float:left;" type="text" name="subject" size="25" maxlength="100" autocomplete="off">
- <input accesskey="s" style="margin-left:2px;" type="submit" name="post" value="New Reply" />
- <input id="spoiler" name="spoiler" type="checkbox">
- <textarea name="body" id="body" rows="5" cols="35"></textarea>
- <input type="file" name="file">
- <input type="text" name="embed" size="30" maxlength="120" autocomplete="off">
- <input type="password" name="password" size="12" maxlength="18" autocomplete="off">
- <input type="hidden" name="hash" value="04fdae57d2a623c4c3445ae40492a6de6887fa60">
- </form>
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement