File: http_sp.pm

package info (click to toggle)
doona 1.0%2Bgit20190108-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 276 kB
  • sloc: perl: 2,287; makefile: 4; sh: 1
file content (119 lines) | stat: -rw-r--r-- 4,051 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package bedmod::http_sp;
use Socket;

# This package is an extension to doona, to check
# for http server vulnerabilities.  Works as an extension to BED too
#
# Tests for request methods and request fields specific to SharePoint
#
# The displayed output may not show particularly long commands but 
# the right stuff is being sent
#
# Might want to mod, depending on desired results.  For example, do a GET on an existing resource
#
# Written by Grid

sub new {
    my $this = {};
    bless $this;
    return $this;
}

sub init {
    my $this = shift;
    %special_cfg=@_;

    $this->{proto}="tcp";

    if ($special_cfg{'p'} eq "") {
        $this->{port}='80';
    } else {
        $this->{port} = $special_cfg{'p'};
    }

    if ($special_cfg{'d'}) { return; }
    $iaddr = inet_aton($this->{target})             || die "Unknown host: $host\n";
    $paddr = sockaddr_in($this->{port}, $iaddr)     || die "getprotobyname: $!\n";
    $proto = getprotobyname('tcp')                  || die "getprotobyname: $!\n";
    socket(SOCKET, PF_INET, SOCK_STREAM, $proto)    || die "socket: $!\n";
    connect(SOCKET, $paddr)                         || die "connection attempt failed: $!\n";
    send(SOCKET, "HEAD / HTTP/1.0\r\n\r\n", 0)      || die "HTTP request failed: $!\n";
}

sub health_check {
    my $this = shift;
    $iaddr = inet_aton($this->{target})             || die "Unknown host: $this->{target}\n";
    $paddr = sockaddr_in($this->{port}, $iaddr)     || die "getprotobyname: $!\n";
    $proto = getprotobyname('tcp')                  || die "getprotobyname: $!\n";
    socket(SOCKET, PF_INET, SOCK_STREAM, $proto)    || die "socket: $!\n";
    connect(SOCKET, $paddr)                         || die "connection attempt failed: $!\n";
    send(SOCKET, "HEAD / HTTP/1.0\r\n\r\n", 0)      || die "HTTP request failed: $!\n";
    my $resp = <SOCKET>;
    if (!$this->{healthy}) {
          if ($resp =~ /HTTP/) {
              $this->{healthy}=$resp;
          }
          # print "Set healthy: $resp";
    }
    return $resp =~ m/^$this->{healthy}$/;
}

sub getQuit {
    return("\r\n\r\n");
}

sub getLoginarray {
    my $this = shift;
    @Loginarray = (
        "GET /default.XAXAX HTTP/1.1\r\nHost: 192.168.43.128\r\n\r\n",
        "GET /XAXAX.html HTTP/1.1\r\nHost: 192.168.43.128\r\n\r\n",
      );
    return (@Loginarray);
}

sub getCommandarray {
    my $this = shift;

    @cmdArray = (
        "x-virus-infected: XAXAX\r\nHost: 192.168.43.128\r\n\r\n",
        "x-irm-cantdecrypt: XAXAX\r\nHost: 192.168.43.128\r\n\r\n",
        "x-irm-rejected: XAXAX\r\nHost: 192.168.43.128\r\n\r\n",
        "x-irm-notowner: XAXAX\r\nHost: 192.168.43.128\r\n\r\n",
        "x-irm-timeout: XAXAX\r\nHost: 192.168.43.128\r\n",
        "x-irm-crashed: XAXAX\r\nHost: 192.168.43.128\r\n\r\n",
        "x-irm-unknown-failure: XAXAX\r\nHost: 192.168.43.128\r\n\r\n",
        "SharePointError: XAXAX\r\nHost: 192.168.43.128\r\n\r\n",
        "X-RequestDigest: XAXAX\r\nHost: 192.168.43.128\r\n\r\n",
        "X-Forms_Based_Auth_Required: XAXAX\r\nHost: 192.168.43.128\r\n\r\n",
        "X-Forms_Based_Auth_Return_Url: XAXAX\r\nHost: 192.168.43.128\r\n\r\n",       
        "X-MS-File-Checked-Out: XAXAX\r\nHost: 192.168.43.128\r\n\r\n",
        "X-RequestToken: XAXAX\r\nHost: 192.168.43.128\r\n\r\n",
        "SPRequestGuid: XAXAX\r\nHost: 192.168.43.128\r\n\r\n",
        "X-UseWebLanguage: XAXAX\r\nHost: 192.168.43.128\r\n\r\n",
        "X-RequestForceAuthentication: XAXAX\r\nHost: 192.168.43.128\r\n\r\n",
        "X-SharePointHealthScore: XAXAX\r\nHost: 192.168.43.128\r\n\r\n",
        "X-MS-InvokeApp: XAXAX\r\nHost: 192.168.43.128\r\n\r\n",
      );
    return(@cmdArray);
}

sub getLogin {
    my $this = shift;
    @login = (
        "GET / HTTP/1.1\r\n",
      );
    return(@login);
}

sub testMisc {         #Put your corner case tests here
    my $this = shift;
    @cmdArray = (
        "GET / HTTP/1.1\r\nHost: 192.168.43.128\r\n\r\n" . "Lotsofheaders: XAXAX\r\n" x 1024 . "\r\n",
      );
    return(@cmdArray);
}

sub usage {
}

1;