Advertisement
Guest User

This shit right here

a guest
Sep 2nd, 2013
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.72 KB | None | 0 0
  1. import requests
  2. from bs4 import BeautifulSoup
  3. from os import walk
  4.  
  5. def main():
  6.     thread="http://lupchan.org/b/res/535.html"
  7.     directory = r"C:\Users\usernamegoeshere\Desktop\dump"
  8.     args=read_fields(thread)
  9.     print "Thread page read"
  10.  
  11.     c=0
  12.     for file in walk(directory).next()[2]:
  13.         upload_file(directory+'\\'+file, args)
  14.         c += 1
  15.         if c>=10: #get again
  16.             args = read_fields(thread)
  17.             c = 0
  18.  
  19.  
  20.  
  21. def upload_file(nom, args):
  22.     args["name"]="Furfriend"
  23.     args["password"]="12345678"
  24.     args["subject"]="Testan"
  25.     args["email"]=""
  26.     args["body"]="Testing, testing, do you read me?"
  27.     args["embed"]=""
  28.     #args["spoiler"]="on"
  29.    
  30.     f = {'file': open(nom, 'rb')}
  31.     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
  32.  
  33.     print response.content #"Error: you didn't make a post ha ha fuck you"
  34.  
  35. def read_fields(thread):
  36.     """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:
  37.    <input name="thread" value="8848" type="text">
  38.    <textarea name="search" style="display:none">1234qwertyuiop</textarea>
  39.    returns {"thread":"8848", "search":"1234qwertyuiop"}
  40.    """
  41.     r = {}
  42.     t=requests.get(thread).text
  43.     doc = BeautifulSoup(t)
  44.     for input in doc.form.find_all("input"):
  45.         if not input['type'] in ("text", "hidden", "password"):
  46.             continue
  47.         print "OK"
  48.         assert input['name'] not in r
  49.         if input.has_attr('value'):
  50.             r[input['name']] = input['value']
  51.         else:
  52.             r[input['name']] = ""
  53.  
  54.     for textarea in doc.form.find_all("textarea"):
  55.         if textarea.string: #actually a <class 'bs4.element.NavigableString'>
  56.             r[textarea['name']] = unicode(textarea.string)
  57.         else: # textarea.string == None
  58.             r[textarea['name']] = ""
  59.     return r
  60.  
  61.  
  62. main()
  63.    
  64.  
  65.  
  66. """
  67. Important values:
  68. "thread"="1234" (no need to change)
  69. "board"="s4s"   (no need to change)
  70. "name" =[name]
  71. "email"=[email]
  72. "subject"=[subject]
  73. "spoiler" (checkbox, "on" or nothing)
  74. "body"=[text]  (textarea)
  75. "file"=[file]  (type=file)
  76. "embed"=[embed]
  77. "password"=[password]
  78.  
  79.  
  80.  
  81. <form name="post" onsubmit="return dopost(this);" enctype="multipart/form-data" action="/post.php" method="post">
  82. <input type="hidden" name="thread" value="8848">
  83. <input type="text" name="firstname" value="">
  84. <input type="hidden" name="board" value="s4s">
  85. <input style="display:none" type="text" name="url" value="">
  86. <textarea name="search" style="display:none">'W&lt;JxUo+ENq QX\@&gt;w,D;O[u0c*(S.^YHpvBT3/t6hMKd29$P:=%|L?~rkeCimA-yb5lgsZa4I1n_&amp;#7G]F!{)z8</textarea>
  87. <input type="text" name="name" size="25" maxlength="35" autocomplete="off">
  88. <input type="text" name="message" value="N}K,{=:AbHr0V#mv5o9F3;e^+Mfh&gt;Z_).~L681]iks%q|WET$Rp&amp;[2@-4BwO7GudCxPSt">
  89. <input style="display:none" type="text" name="text" value="">
  90. <input type="text" name="email" size="25" maxlength="40" autocomplete="off">
  91. <input style="float:left;" type="text" name="subject" size="25" maxlength="100" autocomplete="off">
  92. <input accesskey="s" style="margin-left:2px;" type="submit" name="post" value="New Reply" />
  93. <input id="spoiler" name="spoiler" type="checkbox">
  94. <textarea name="body" id="body" rows="5" cols="35"></textarea>
  95. <input type="file" name="file">
  96. <input type="text" name="embed" size="30" maxlength="120" autocomplete="off">
  97. <input type="password" name="password" size="12" maxlength="18" autocomplete="off">
  98. <input type="hidden" name="hash" value="04fdae57d2a623c4c3445ae40492a6de6887fa60">
  99.  
  100. </form>
  101. """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement