Name: Anonymous 2007-09-01 16:50 ID:wsG5AKEa
Why has no one coded a 4chan directory dumper for Linux yet? Are there that few people with *nix?
#!/usr/bin/php
<?
/*
:: 4chan image stripper ::
---------------------------
Type: PHP script
Version: 0.5-suave
Requires: wget and PHP (recommended 5>, should work most anywhere PHP4 is accepted)
Written By: Anonymous (>^_^)>=[]
Usage
-----------
Run from the command line, i.e.
$ php ./4cis.php
The above line would use the config in this file to determine what
forum and thread to strip
Also, it accepts parameters!
$ php ./4cis.php --sauce=http://some/thread/on/r/ --forum=r --mode=onebigwget --exec=false
The above line would override the internal config, thus the sauce thread
would be --sauce, the target forum --forum and the mode (see below) as
--mode.
Of course, try --help if you're stuck ;)
Bugs
-----------
- Having trouble with /r/. Something isn't wget'ing properly.
- Some users experience the following with PHP-CLI
PHP Warning: mime_magic:
type regex BEGIN[[:space:]]*[{] application/x-awk invalid in Unknown on line 0
This is a bug in certain 4.x version of PHP, so not my fault :)
Uncomment the error_reporting() statement below or upgrade your PHP!
Notes
-----------
Some of you had trouble with this, but I'll give you a hint:
READ THE COMMENTS. yarly
Changelog
-----------
0.5-suave
- Default for $doexec is now 'true'
0.4-kawaii
- Support for most forums as well as full support of command-line arguments
( --sauce, --forum, --mode and --help ).
- Better support for image formats (png and such)
0.3-dogmongler
- Added more forum support as well as preliminary functions for command-line args
0.2-/b/tard
- Added support for more forums: /h/, /k/ (for those weapon threads!), and /wg/.
Todo
-----------
- Currently all config is done in here, cli args later
Special Thanks
---------------
To anonymous for posting so many womens that I felt compelled to write
a PHP script. Also to anonymous for AIDs. Thank you.
-Anon
*/
# PHP developers [uncomment the next line to] hide errors!
#error_reporting( E_NONE );
# CONFIG
# These are config things
# Note that any config directives set in the command line will override these!
# Currently supported foums are /k/, /h/, /wg/, /s/ and /b/ ;)
# Feel free to try other forums too - I'm just a lazy anon
# Command-Line Equivelant: --forum
$FORUM = 'b'; //which forum?
# Which mode? valid modes are: onebigwget, listwget and list and all
# - onebigwget - returns one big wget statement with header forged
# - listwget - a list of wget commands, each with forged header
# - list - a list of URLs, line break (\n) seperated
# - all - do each one
# Command-Line Equivelant: --mode
$MODE = 'onebigwget';
# sauce.txt should be the source HTML of the target thread page -
# can also be a URL to a thread
#
#$sauce = "sauce.txt";
# Command-Line Equivelant: --sauce
# forge the headers for wget XD
$header = " --header='User-Agent: Mozilla/5.0 (X11) Gecko/20060601 Firefox/2.0.0.2'";
# prep som vars
$wgetlist = $list = '';
$onebigwget = "wget" . $header;
$imgtypes = array( 'jpg', 'png', 'gif', 'bmp' );
$doexec = true; //default as of 0.5-suave
if( $_REQUEST['sauce'] || array_filter( $argv, "is_sauce" ) )
{
$sauce = $_REQUEST['sauce'] ? $_REQUEST['sauce'] : $sarray = array_filter( $argv, "is_sauce" );
if( is_array( $sauce ) )
{
sort( $sarray );
$sarray = $sarray[ 0 ];
$sarray = explode( "=", $sarray );
$sauce = $sarray[1];
}
}else
$sauce = "http://img.4chan.org/b/res/22834898.html#22834898";;
if( array_filter( $argv, "is_mode" ) )
{
$marray = array_filter( $argv, "is_mode" );
sort( $marray );
$marray = $marray[ 0 ];
$marray = explode( "=", $marray );
$MODE = $marray[1];
}
if( array_filter( $argv, "is_forum" ) )
{
$farray = array_filter( $argv, "is_forum" );
sort( $farray );
$farray = $farray[ 0 ];
$farray = explode( "=", $farray );
$FORUM = $farray[1];
}
if( array_filteR( $argv, 'is_exec' ) )
{
$doexec = true;
}
if( array_filter( $argv, "is_help" ) )
{
$version = '0.5-suave';
echo "
4chan Image Stripper ({$version})
Usage:
php ./4cis.php [--sauce=URL] [--forum=TARGETFORUM] [--mode=MODE] [--exec=[true[false]]]
php ./4cis.php [--help]
--sauce - Use this instead of source in config
--forum - Target 4chan forum
--mode - Valid modes are: list, wgetlist, onebigwget or all
list - Display results as a list of URLs, \\n seperated
wgetlist - Display results with wget commands on each line
onebigwget - Display results as one long wget string
all - Display each of the aforementioned
--exec - Set this =[true[false]] to turn on/off automatic download (only with wget options)
--help - Display this message
";
die;
}
################ DON'T NEED TO CONFIGURE BELOW THIS LINE LULZ ##################
switch( $FORUM )
{
default:
case 'b':
$template = "http://img.4chan.org/{$FORUM}/src/";
break;
case 'k':
$template = "http://zip.4chan.org/{$FORUM}/src.cgi/";
break;
case 'h':
case 's':
$template = "http://cgi.4chan.org/{$FORUM}/src/";
break;
case 'hr':
$template = "http://orz.4chan.org/{$FORUM}/src/";
break;
case 'r':
$template = "http://cgi.4chan.org/{$FORUM}/src.cgi/";
break;
case 'wg':
$template = "http://orz.4chan.org/{$FORUM}/src.cgi/";
break;
}
$sauce = file( $sauce );
# get img URLs - GO!
foreach( $sauce as $line )
{
if( strpos( $line, $template ) !== FALSE )
{
$start = strpos( $line, $template );
$line = substr( $line, $start );
$end = $dont = false;
foreach( $imgtypes as $tkey => $type )
{
if( strpos( $line, $type ) !== FALSE && ( strpos( $line, $type ) < $end || !$end ) )
{
$end = strpos( $line, $type );
}
}
if( !$dont )
{
reset( $imgtypes );
$line = substr( $line, 0, $end+3 );
if( $MODE == 'wgetlist' || $MODE == 'all' )
$wgetlist .= 'wget ' . $line . $header . "\n";
if( $MODE == 'onebigwget' || $MODE == 'all' )
$onebigwget .= " " . $line;
if( $MODE == 'list' || $MODE == 'all' )
$list .= $line . "\n";
}
}
}
$sep = "-------------------------------------\n";
# which mode? OUTPUT GO!
if( $MODE == 'list' || $MODE == 'all' )
{
echo $sep;
echo "url list\n";
echo $sep;
echo $list . "\n";
}
if( $MODE == 'wgetlist' || $MODE == 'all' )
{
echo $sep;
echo "wget list\n";
echo $sep;
echo $wgetlist . "\n";
}
if( $MODE == 'onebigwget' || $MODE == 'all' )
{
echo $sep;
echo "one big wget\n";
echo $sep;
echo $onebigwget . "\n";
if( $doexec )
{
exec( $onebigwget );
exec( "rm -vf ./*.1" );
}
}
# we're done here.
# anon
//FUNCTIONS
function is_exec( $var )
{
if( strpos( $var, '--exec=true' ) !== FALSE )
return true;
else
return false;
}
function is_help( $var )
{
if( strpos( $var, '--help' ) !== FALSE )
return true;
else
return false;
}
function is_sauce( $var )
{
if( strpos( $var, '--sauce=' ) !== FALSE )
return true;
else
return false;
}
function is_mode( $var )
{
if( strpos( $var, '--mode=' ) !== FALSE )
return true;
else
return false;
}
function is_forum( $var )
{
if( strpos( $var, '--forum=' ) !== FALSE )
return true;
else
return false;
}
?>
$ php crapflood.php -t dis dis.4chan.org/prog "ONE WORD, THE FORCED CRAPFLOOD, THREAD FLOODED"
function is_sauce( $var )
{
return (strpos( $var, '--sauce=' ) !== FALSE);
}$ yo.pl
Usage: yo.pl COMMAND [OPTION]...
Allows to post and do other cruel things to 4chan's
boards. Use 'yo.pl COMMAND' for help on specific commands
Available commands are:
post - floods 4chan's boards with images
smile - smile :)
sstorm - Ghost-bumps threads from last page, less blatant version
unk1 - flood board with weird smiley
whoa - posts image of nanohafan person to specific thread
$
% yo.pl smile
Allows to post and do other cruel things to 4chan's boards.