The Web Application Hacker’s Handbook Discovering and Exploiting Security Flaws


N OT E If you write your own code to generate



Download 5,76 Mb.
Pdf ko'rish
bet817/875
Sana01.01.2022
Hajmi5,76 Mb.
#293004
1   ...   813   814   815   816   817   818   819   820   ...   875
Bog'liq
3794 1008 4334

N OT E

If you write your own code to generate 

POST


requests, you will need to

include a valid 

Content-Length



header that specifies the actual length of the

HTTP body in each request, as in the preceding code. If an invalid 

Content-


Length

is submitted, most web servers will either truncate the data you submit

or wait indefinitely for more data to be supplied.

Chapter 13 



Automating Bespoke Attacks



481

70779c13.qxd:WileyRed  9/14/07  3:14 PM  Page 481




In order to send our requests, we need to open network connections to the

target web server. Java makes the task of opening a TCP connection, submit-

ting data, and reading the server’s response extremely easy:

String issueRequest(String req) throws UnknownHostException, IOException

{

Socket socket = new Socket(host, port);



OutputStream os = socket.getOutputStream();

os.write(req.getBytes());

os.flush();

BufferedReader br = new BufferedReader(new InputStreamReader(

socket.getInputStream()));

StringBuffer response = new StringBuffer();

String line;

while (null != (line = br.readLine()))

response.append(line);

os.close();

br.close();

return response.toString();

}

Having obtained the server’s response to each request, we need to parse it



to extract the relevant information to enable us to identify hits in our attack.

Let’s start by simply recording two interesting items — the HTTP status code

from the first line of the response and the total length of the response:

String parseResponse(String response)

{

StringBuffer output = new StringBuffer();



output.append(response.split(“\\s+”, 3)[1] + “\t”);

output.append(Integer.toString(response.length()) + “\t”);

return output.toString();

}

Finally, we now have everything in place to launch our attack. We just need



some simple wrapper code to call each of the preceding methods in turn and

print out the results, until all our requests have been made and 

nextRequest

returns 


false

void doAttack()



{

System.out.println(“param\tpayload\tstatus\tlength”);

String output = null;


Download 5,76 Mb.

Do'stlaringiz bilan baham:
1   ...   813   814   815   816   817   818   819   820   ...   875




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish