Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

4chan dump script

Name: Anonymous 2010-02-17 14:03

any ideas on how i could improve this?

#!/bin/bash

# 4chan image dumper -- rimjob.sh -- ENTERPRISE QUALITY BASH SCRIPT
# last update: 16.02.2010 - Version 0.9.7
# direct cool stories, monnies, bug reports, etc. to blargh on #/g/tv - Rizon or blargh.macfag@googlemail.com
#
# improved rape.sh script (v5) => http://pastebin.com/f70ec1e29
#
# creates automagically new threads
# posts old thread URL into new thread and vice versa
# self tuning sleep timer to avoid flood
# uploads biggest files at first to avoid flood protection kicking in too early (default)
# to upload your shit sorted by name add -s as option
# http proxy support

# todo:
# fix those vars
# change flood retry function
# improve proxy function
# handle curl failures properly
# add some curl timeouts
# needs more colors

##### CHECK IF CURL IS AVAILABLE
CURL=`which curl`
if [ -z "$CURL" ]; then
    echo "This script depends on cURL, make sure it's installed and in your path."
    exit 1
fi

##### CHANGE ME
USERAGENT="furryfox"
PWD=ad8fas3fsw
SLEEP=10
PROXY="" # edit like this: "-x proxyURL:port"
##### YOU MAY CHANGE THIS TOO
TMP=`mktemp -t rimjob.curlout.XXXX`
TMP2=`mktemp -t rimjob.lsout.XXXX`
##### OMG WTF ARE YOU DOING??
BIFS=$IFS; SUM=0; CNT=1; DUP=0; UPD=0; DRP=0; TRD=1; NWTRD=0; FLR=0
##### LOL COLORS
BLACK=\\033[30m; RED=\\033[31m; GREEN=\\033[32m; YELLOW=\\033[33m
BLUE=\\033[34m; MAGENTA=\\033[35m; CYAN=\\033[36m; WHITE=\\033[37m
L_BLACK=\\033[1\;30m; L_RED=\\033[1\;31m; L_GREEN=\\033[1\;32m; L_YELLOW=\\033[1\;33m
L_BLUE=\\033[1\;34m; L_MAGENTA=\\033[1\;35m; L_CYAN=\\033[1\;36m; L_WHITE=\\033[1\;37m
B_BLACK=\\033[40m; B_RED=\\033[41m; B_GREEN=\\033[42m; B_YELLOW=\\033[43m
B_BLUE=\\033[44m; B_MAGENTA=\\033[45m; B_CYAN=\\033[46m; B_WHITE=\\033[47m
C_RESET=\\033[m

replies() {
    cat $TMP | awk '/Post successful!/ {print "POST SUCCESSFUL!"} /Error: Duplicate file entry detected./ {print "Duplicate."} /Error: Flood detected./ {print "Flood detected."} /Max limit of/ {print "Max limit reached."} /Abnormal reply/ {print "Abnormal reply."} /Error: No file selected./ {print "No file selected."} /Error: Cannot find record./ {print "Cannot find record."} /Error: No text entered./ {print "No text entered."} /404 - Not Found/ {print "404 - Not found."} /Thread specified does/ {print "Thread does not exist."} /You are banned ;_;/ {print "Banned."} /Error: Field too long./ {print "Field too long."} /Error: File too large./ {print "File too large."} /Detected possible malicious code in image file./ {print "Detected possible malicious code in image file."} /Error: Image resolution is too large./ {print "Image resolution too large."} /Updating index.../ {print "Updating index..."} /Error: Upload failed./ {print "Upload failed."} /Error: Invalid tag specified./ {print "Invalid tag."} /Image file contains embedded archive./ {print "Image contains embedded archive."} /This board doesn/ {print "This board does not exist."} /Please post about something else!/ {print "Post something else!"}'
}

rim_stats() {
    echo -ne "\nThreads: $TRD\nUploaded: $UPD of $SUM\nDupes: $DUP\nDropped: $DRP (flood)\nFailures: $FLR\n"
}

clean_up() {
    rm -f $TMP $TMP2
}

choose() {
echo -ne "Choose a board >
 (a,b,c,d,e,f,g,gif,h,hr,k,m,o,p,r,s,t,u,v,w,wg,i,ic,cm,y,r9k
  3,adv,an,cgl,ck,co,fa,fit,int,jp,lit,mu,n,new,po,sci,sp,tg,toy,trv,tv,x): "
read -e IBOARD

case "$IBOARD" in
    a|b|c|g|k|m|o|p|v|w|cm|an|ck|co|mu|po|tg|tv|x|gif|h|r|s|t|i|ic|d|e|hr|u|wg|y|cgl|n|r9k|3|adv|int|lit|sci|new)
    ISERVER="boards"
    PSERVER="sys"
    POST="post";;
    f|fk|rs)
    echo -e "\n/$IBOARD/ is not supported\n"
    choose;;
    *)
    echo -e "\n/$IBOARD/ doesn't exist yet :|\n"
    choose;;
esac
}

trap "clean_up; rim_stats; exit 1" 1 2 15

clear
choose
#####
BOARD="http://$PSERVER.4chan.org/$IBOARD/$POST"
#####
echo -ne "\nSelect dir(s) to dump, separate multiple dirs with a semicolon
 (eg. /users/derp/pics;/users/hurrr/durr derp):\n"
read ADIR
IFS=";"
for DIR1 in $ADIR; do
    IFS=$BIFS
    cd "$DIR1"
    if [ "$1" = "-s" ]; then
        # sorted by name
        ls -1 | sed "s,^\([^/]\),${DIR1}/\1," >> $TMP2; else
        # sorted by size
        ls -1S | sed "s,^\([^/]\),${DIR1}/\1," >> $TMP2
    fi
done

echo
cat $TMP2

SUM=`cat $TMP2 | grep -c .`
echo -ne "\n${GREEN}${SUM} files selected.${C_RESET}\n"

echo -ne "\nName>
 (leave blank for none): "
read -e NAME
echo -ne "\nEmail>
 (leave blank for none): "
read -e EMAIL
echo -ne "\nInitial subject>
 (leave blank for none): "
read -e ISUB
SUB2=$ISUB
echo -ne "\nInitial comment>
 (leave blank for none): "
read -e ICOM
echo -ne "\nThread ID>
 (eg. 1993711 or blank for new thread): "
read -e URL

##### CHECK IF WE CREATE A NEW THREAD OR NOT
if [ "$URL" = "" ]; then
    NWTRD=1
fi

echo -e "\n\n${L_BLUE}starting dump. pause with${C_RESET}${BLUE} ctrl-s${L_BLUE}, continue with${C_RESET}${BLUE} ctrl-q.${C_RESET}"

while read FILE; do
    if [ -d "$FILE" ]; then
        echo -e "\n${L_RED} * $FILE is a directory.${C_RESET}"
        let "FLR += 1"
        continue
    fi
    if [ ! -f "$FILE" ]; then
        echo -e "\n${L_RED} * $FILE doesn't exist.${C_RESET}"
        let "FLR += 1"
        continue
    fi
   
    BFILE=`basename "$FILE"`
    SIZE=`du -sh "$FILE" | awk '{print $1}'`
   
##### MAIN DUMPER
    echo -e "\n[$TRD/$CNT/$SUM] [ ($SIZE) $BFILE => http://$ISERVER.4chan.org/$IBOARD/res/$URL ]"
    curl -# $PROXY -A $USERAGENT -F "resto=$URL" -F "name=$NAME" -F "email=$EMAIL" -F "sub=$ISUB" -F "com=$ICOM" -F "upfile=@$FILE" -F "pwd=$PWD" -F "mode=regist" -F "submit=submit" $BOARD > $TMP
    ANSW=`replies`
    echo " >> $ANSW"

##### GET THE THREAD URL
    if [ "$URL" = "" ]; then
        URL=`cat $TMP | egrep -o 'thread:0,no:[0-9]+' | egrep -o '[0-9]{4,}'`
    fi

##### FLOOD DETECTION RETRY #1
    if [ "$ANSW" = "Flood detected." ] || [ "$ANSW" = "Updating index..." ] || [ "$ANSW" = "Upload failed." ] || [ "$ANSW" = "" ]; then
        echo -e "${L_RED}[Retry #1/2] [ ($SIZE) $BFILE => http://$ISERVER.4chan.org/$IBOARD/res/$URL ]${C_RESET}"
        sleep 10
        if [ "$ANSW" = "Flood detected." ]; then
            let "SLEEP += 5"
        fi
        curl -# $PROXY -A $USERAGENT -F "resto=$URL" -F "name=$NAME" -F "email=$EMAIL" -F "sub=$ISUB" -F "com=$ICOM" -F "upfile=@$FILE" -F "pwd=$PWD" -F "mode=regist" -F "submit=submit" $BOARD > $TMP
        ANSW=`replies`
        echo " >> $ANSW"
    fi

##### FLOOD DETECTION RETRY #2
    if [ "$ANSW" = "Flood detected." ]; then
        echo -e "${L_RED}[Retry #2/2] [ ($SIZE) $BFILE => http://$ISERVER.4chan.org/$IBOARD/res/$URL ]${C_RESET}"
        echo -e "${L_MAGENTA}SET THE SLEEP TIMER A BIT HIGHER IF YOU STILL GET THE FLOOD DETECTED MESSAGE!${C_RESET}"
        sleep 7
        let "SLEEP += 5"
        curl -# $PROXY -A $USERAGENT -F "resto=$URL" -F "name=$NAME" -F "email=$EMAIL" -F "sub=$ISUB" -F "com=$ICOM" -F "upfile=@$FILE" -F "pwd=$PWD" -F "mode=regist" -F "submit=submit" $BOARD > $TMP
        ANSW=`replies`
        echo " >> $ANSW"
        if [ "$ANSW" = "Flood detected." ]; then
            let "DRP += 1"
            echo " >> Picture dropped!"
        fi
    fi

##### CREATE NEW THREAD WHEN PIC LIMIT IS REACHED, POST A LINK TO THE OLD THREAD IN THE NEW THREAD AND VICE VERSA
    if [ "$ANSW" = "Max limit reached." ]; then
        let "TRD += 1"
        COM2="Thread #$TRD
Continued from: >>$URL"
        echo -e "${L_GREEN}[$TRD/$CNT/$SUM] [ ($SIZE) $BFILE => Creating new thread. ]${C_RESET}"
        curl -# $PROXY -A $USERAGENT -F "name=$NAME" -F "email=$EMAIL" -F "sub=$SUB2" -F "com=$COM2" -F "upfile=@$FILE" -F "pwd=$PWD" -F "mode=regist" -F "submit=submit" $BOARD > $TMP
        ANSW=`replies`
        URL2=$URL
        URL=`cat $TMP | egrep -o 'thread:0,no:[0-9]+' | egrep -o '[0-9]{4,}'`
        echo " >> $ANSW"
        echo -e "${GREEN} >> Posting new thread URL into old thread...${C_RESET}"
        curl -# $PROXY -A $USERAGENT -F "resto=$URL2" -F "name=$NAME" -F "email=$EMAIL" -F "com=Continued here: >>$URL" -F "pwd=$PWD" -F "mode=regist" -F "submit=submit" $BOARD > /dev/null
        ANSW=`replies`
        echo " >> $ANSW"
    fi

##### KEEP POSTING AFTER DUPLICATE
    if [ "$ANSW" = "Duplicate." ]; then
        let "DUP = DUP + 1"
        let "CNT = CNT + 1"
        continue
    fi

##### KEEP POSTING IF A NEGLIGIBLE FAILURE OCCURS
    if [ "$ANSW" = "Image resolution too large." ] || [ "$ANSW" = "Cannot find record." ] || [ "$ANSW" = "Abnormal reply." ] || [ "$ANSW" = "Detected possible malicious code in image file." ] || [ "$ANSW" = "Error: File too large." ] || [ "$ANSW" = "Updating index..." ] || [ "$ANSW" = "Upload failed." ] || [ "$ANSW" = "Image contains embedded archive." ]; then
        let "FLR += 1"
        let "CNT += 1"
        continue
    fi
   
##### QUIT SCRIPT AFTER A SERIOUS FAILURE
    if [ "$ANSW" = "No file selected." ] || [ "$ANSW" = "No text entered." ] || [ "$ANSW" = "404 - Not found." ] || [ "$ANSW" = "Thread does not exist." ] || [ "$ANSW" = "Banned." ] || [ "$ANSW" = "Field too long." ] || [ "$ANSW" = "This board does not exist." ] || [ "$ANSW" = "Post something else!" ]; then
        clean_up
        rim_stats
        exit 1
    fi
   
##### IF CURL FAILS OR 4CHAN REPLY IS NOT SPECIFIED
    if [ "$ANSW" = "" ]; then
        echo -e "${L_RED}Curl failed or 4chan reply is not specified.${C_RESET}"
        cat $TMP >> $HOME/Desktop/rimjob_debug.txt
        let "FLR += 1"
        let "CNT += 1"
        continue
    fi
       
    let "UPD += 1"
    let "CNT += 1"
    ICOM=""
    ISUB=""

##### IGNORE TIMEOUT IF ALL PICS WERE POSTED OR A NEW THREAD WAS CREATED
    if [ "$CNT" -gt "$SUM" ] || [ "$NWTRD" = "1" ]; then
        NWTRD=0
        continue
    fi
   
    echo -e "\n * Waiting $SLEEP seconds..."
    sleep $SLEEP
    continue
done < $TMP2
clean_up; rim_stats; exit 0

Name: Μαντείο 2010-03-02 8:45

This thread is going to go on forever, and OP is never going to get what he wants from it. Long after OP leaves, this thread will have 400 posts before threadstop.

Newer Posts