[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]

/tts/ - The Trolling Society

Where our din is

Catalog

8chan Bitcoin address: 1NpQaXqmCBji6gfX8UgaQEmEstvVY7U32C
The next generation of Infinity is here (discussion) (contribute)
A message from @CodeMonkeyZ, 2ch lead developer: "How Hiroyuki Nishimura will sell 4chan data"
Email
Comment *
File
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Options
dicesidesmodifier
Password (For file and post deletion.)

Allowed file types:jpg, jpeg, gif, png, webm, mp4, swf, pdf
Max filesize is 8 MB.
Max image dimensions are 10000 x 10000.
You may upload 3 per post.


File: 1442073601015.jpg (173.8 KB, 1131x707, 1131:707, assassins-creed-4-black-fl….jpg)

 No.16

python script for raiding threads

Trying to figure out how to post multiple images at once


# -*- coding: utf-8 -*-
from time import sleep
import requests
import argparse
import os

parser = argparse.ArgumentParser(description='Dump a folder to an 8chan thread')
parser.add_argument('-f','--folder', help='folder to upload images from', type=str, required=True)
parser.add_argument('-b','--board', help='board to post to', required=True)
parser.add_argument('-t','--thread', help='thread to post to', type=int, required=True)
parser.add_argument('-d','--delay', help='delay between posting', type=int, required=True)
args = vars(parser.parse_args())

DIRECTORY = args['folder']
files = []
for f in os.listdir(DIRECTORY):
if os.path.splitext(f)[1].lower() in ('.jpg', '.jpeg', '.png', '.gif', '.webm', '.mp4'):
files.append(os.path.join(DIRECTORY, f))
total = len(files)

url = 'https://8ch.net'
board = args['board']
thread = args['thread']
body = ''
delay = args['delay']

data = {
'board' : board,
'thread' : thread,
'name' : '',
'email' : '',
'subject' : '',
'body' : '',
'embed' : '',
'dx' : '',
'dy' : '',
'dz' : '',
'password' : 'ayylmao',
'json_response' : '1',
'post' : 'New Reply'
}

headers = {
'referer' : '',
'user-agent' : 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0',
'accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'accept-language' : 'en-US,en;q=0.5',
'cache-control' : 'max-age=0'
}

headers['referer'] = url + '/' + board + '/'

for i in range(0, total):
status = ''
while 'redirect' not in status:
#data['body'] = str(i + 1) + '/' + str(total)
f = {'file': open(files[i], 'rb')}
status = requests.post(url + '/post.php', data=data, headers=headers, files=f).text
print status
print 'Waiting ' + str(delay) + ' seconds...'
sleep(delay)

https://8ch.net/tech/res/350963.html#365711

https://8ch.net/b/res/4117063.html

 No.17

>>16

Where do you guys add the thread url and dump directory path? Not a programmer


 No.18

>>17

looks like if you just find a way to send, say, 3 files at once then 8chan will accept it


 No.19

>>18

sending multiple files at once is easy


files = {'file': open('/home/anon/Pictures/1.png', 'rb'), 'file2': open('/home/anon/Pictures/2.png', 'rb'), 'file3': open('/home/anon/Pictures/3.png', 'rb'), 'file4': open('/home/anon/Pictures/4.png', 'rb')}
r = requests.post('https://8ch.net/post.php', data=data, headers=headers, files=files)

doing so with a loop, isn't


 No.20

>>19

it's easy, slice your files array into how many files you want per post into a dict called posts

then iterate over it


 No.22

>>20

Wouldn't there be issues if it wasn't a nice number?

eg: Posting 5 files with each post, but there are only 53 files total.

And what would you do with the loop?

Obviously it needs to be changed, because right now it loops over each file in the directory, but if you're uploading multiple images the loop count and file count get off.


 No.24

>>22 (check'd)

>eg: Posting 5 files with each post, but there are only 53 files total.


>>> open('', 'rb')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 22] invalid mode ('rb') or filename: ''

there would be a definite issue


 No.25

>>22 (check'd)

no, here's an example I stole:


>>> def each_slice(iterable, size):
... current_slice = []
... for i in iterable:
... current_slice.append(i)
... if len(current_slice) >= size:
... yield current_slice
... current_slice = []
... if current_slice:
... yield current_slice
...
>>> files = ['dongs.png','dongs.jpg','dongs.tiff','dongs.webm','dongs.mp4']
>>> maxfiles = 2
>>> for file in each_slice(files, maxfiles):
... print file
...
['dongs.png', 'dongs.jpg']
['dongs.tiff', 'dongs.webm']
['dongs.mp4']


 No.26

>>25

Cool thanks, that helps alot


 No.27

>>16

how I'd do this in python is take the files array, have an argument for maxfiles, then slice the array (i think you can do this with numpy or implement this yourself) by maximages into an array called posts.

the default maximages would be 1.

then you'd just iterate over posts, and your counter would be accurate.

you can also do other things like check if the board allows certain types of files, and only dump those files, according to this api endpoint:

https://8ch.net/settings.php?board=tech

unforunately, max images allowed per post is not exposed, so it can't be automatic by parsing json.

I helped fix the multiple file handling and board localization in this script, by the way:

https://raw.githubusercontent.com/Karunamon/muda/ruby/muda.rb


 No.28

>>27

>array called posts

sorry I meant a hash table, which would be python dict

i dont python much sorry


 No.29

>>16

I just want to say I love you anon

>>>/b/4117063

Best not let this fall into the wrong hands though, I can imagine spam posters would love to use a script to derail threads without effort


 No.31

>>16

Seems like a great tool for shitposters to Travis threads without effort

think of the shitposting possibilities heuheuehuheu!


 No.32

>>31

basically

I use it to dump stuff on /wx/, makes life easier

I really wish I could take advantage of multi-file uploading though, it would massively cut down on the time needed to dump a folder

I've got no idea on how to go about implementing it though


 No.33

>>29

yeah no problem

should be obvious, but if you want it to post with progress (ex: 1/50, 2/50, 3/50, etc), just uncomment


#data['body'] = str(i + 1) + '/' + str(total)


 No.34

>>32

>it would massively cut down on the time needed to dump a folder

I mean, being able to dump multiple images at a time would be great because there's a captcha every 50 posts, so being able to post multiple images reduces the number of posts required, which reduces the number of captchas


 No.35

>>16

How do I run this shit?


 No.36

>>35

its not that hard bro

save it as script.py

run it in command line as python script.py -f [folder] -b [board name without slashes] -t [thread number] -d [delay between post in seconds]


 No.37

>>36

Pics? This shit reminds me of delayclose


 No.38

>>37

pics of fucking what? The command window?

nigger just run it yourself


 No.39

File: 1442077475440.png (43.28 KB, 843x549, 281:183, 1441768413876.png)

>>38

Getting error


 No.40

>>39

Oh that's why I can't get the script to work.

I forgot to install a python interpreter.


 No.41

>>39

you have python 3 installed, but the script was written for python 2

try doing


2to3 -w dump.py

https://docs.python.org/2/library/2to3.html


 No.42

File: 1442077695217.png (39.14 KB, 843x549, 281:183, 1441769400442.png)

>>41

uninstalled python 3 and installed python 2 but still getting error


 No.43

>>42

pip install requests


 No.44

>>43

How do I do that?


 No.45

>>44 (check'd)

you literally type it in to the command prompt


 No.46

>>45

Then why is it not working? Kek


 No.47

>>46

1. Download/save script

2. Install python2

3. cd to the same directory as the script

4. Type


pip install requests

into the command prompt

5. Type


python dump.py

It should spoonfeed you on what to do next


 No.48

>>47

Already installed pip


C:\Users\John\Desktop>python dump.py -f [E:\Wallpaper\50 Universe Artistic Wal
lpapers HD 1600 X 1200] -b [b] -t [4117063] -d [10]
Traceback (most recent call last):
File "dump.py", line 3, in <module>
import requests
ImportError: No module named requests

C:\Users\John\Desktop>


 No.49

>>48

You have to install requests.


pip install requests

pip is python's package manager


 No.50

>>49

I installed it manually.


 No.51

>>50

If you installed requests using


pip install requests

then you wouldn't be getting this error


No module named requests


 No.53

>>51

You know I'm using windows, right? if did it the way you instructed here

>>47

I'm gonna get

>'pip' is not recognized as an internal or external command, operable program or batch file.

That why i installed it manually


 No.54

>>53

Make sure you're in the same directory as pip.exe Jesus fucking shit


 No.55

File: 1442078739331.png (2.9 KB, 500x110, 50:11, 1441770841443.png)

>>53

works on my machine

is pip in your PATH?


 No.56

>>53

Not him, an not sure if you're mentally fucking deficient, but he clearly said to cd to the same directory as the script


 No.57

>>56

>>55 (check'd)

>>54

Had to install request module.

>invalid int value


 No.58

>>57

It's telling you exactly what the problem is.

[4117063] isn't a valid integer.

4117063 is.

You don't need to put [ ] around it, in fact, it fucks up if you do.


 No.59

>>46

If I had to guess, its because you need to be in the same directory as pip.exe


 No.60

>>41

>>4117819

>>4117815

>>4117811

>>4117808

>>4117806

>>4117802

>>4117799

>>4117795

>>4117793

Don't mind me, just testing to see if it works with symbolic links, this could be useful for building dump folders


 No.61

>>60

Link to interpreter?


 No.62

>>61


sudo apt-get install python

oh that right, you're using Windows, which can't into symbolic linking as well kek

Just get python for Windorks from their website


 No.65


 No.66

>>65

So unzip the rar and run the code?

Thanks anon.


 No.67

File: 1442080164889.jpg (35.56 KB, 493x497, 493:497, 1441769275277.jpg)

>>66 (check'd)

Something like that


 No.68

>>66 (check'd)

No you dumb asshole.

DO NOT UNZIP THAT RAR.

It'll install gentoo and crash your shit.

see

>>62


 No.69


#!/bin/bash

function 8dump()
{
if [[ "$#" -ne "3" ]]; then
printf 'Usage: %s [TARGET] [DIRECTORY] [DELAY]\n' ${FUNCNAME}
return
fi

local _link=$1
local _board=$(printf $1 | sed 's/^.*net\///; s/\/.*//')
local _thread=$(printf $1 | sed 's/^.*res\///; s/\..*//')

local _count=0
local _total=$(ls "$2" | wc -l)

for i in "$2"*; do
_count=$(($_count+1))

printf 'File: "%s" > Response: ' "$i"
curl --user-agent "Mozilla/5.0" \
--form "board=$_board" \
--form "body=$_count" \
--form "file=@$i" \
--form "json_response=1" \
--form "password=as98dfyasd" \
--form "post=New Reply" \
--form "thread=$_thread" \
--form "email=sage" \
--referer "https://8ch.net" \
"https://8ch.net/post.php"
sleep $3
printf '\n'
done
}

8dump $1 $2 $3;




[Return][Go to top][Catalog][Post a Reply]
[]
[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]