File: socks5.pm

package info (click to toggle)
doona 1.0%2Bgit20190108-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 268 kB
  • sloc: perl: 2,287; makefile: 4; sh: 1
file content (109 lines) | stat: -rw-r--r-- 2,808 bytes parent folder | download | duplicates (4)
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
package bedmod::socks5;
use Socket;

# socks5 plugin
#
# not yet tested, got bored just by looking at the protocol

# \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
# create a new instance of this object
sub new {
    my $this = {};
    $this->{username} = undef;
    $this->{password} = undef;
    bless $this;
    return $this;
}

# \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
# initialise some parameters
sub init {
    my $this = shift;
    %special_cfg = @_;

    # Set protocol tcp/udp
    $this->{proto} = "tcp";

    # check for missing args, set target and host
    # every module has to do this
    if   ( $special_cfg{'p'} eq "" ) { $this->{port} = '1080'; }
    else                             { $this->{port} = $special_cfg{'p'}; }
    $this->{sport} = 0;
    $this->{vrfy}  = "";

    if ( ( $special_cfg{'u'} eq "" ) || ( $special_cfg{'v'} eq "" ) ) {
        &usage();
        exit(1);
    }

    $this->{username} = $special_cfg{'u'};
    $this->{password} = $special_cfg{'v'};
}

# \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
# how to quit ?
sub getQuit {
    return ("");
}

# \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
# what to test without doing a login before
# ..mainly the login stuff *g*
sub getLoginarray {
    my $this = shift;
    @Loginarray = ("");
    return (@Loginarray);
}

# \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
# which commands does this protocol know ?
sub getCommandarray {
    my $this = shift;

    # all there is to test is the username as far as it seems...
    @cmdArray = (
        "XAXAX\n",

        # if the programmer is clever enough he always receives the packet
        # in a buffer which is bigger than ~0x128 :)
        "\x05\x01\x00\x04\xFF\x10"
        ,    # check for buffer access which should give a gpf
        "\x05\x01\x00\x04\x50\x10"    # same here different value... lame :)

    );
    return (@cmdArray);
}

# \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
# what to send to login ?
sub getLogin {                        # login procedure
    my $this = shift;
    $count1 = length( $this->{username} );
    $count2 = length( $this->{password} );

    @login = (

        #protocol version #nr. of authentication methods #username+password
        "\x05\x01\x02",

        #protocol #username len #username #pass len #password
        "\x05$count1$this->{username}$count2$this->{password}",
    );
    return (@login);
}

# \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
# here we can test everything besides buffer overflows and format strings
sub testMisc {
    my $this = shift;
    return ();
}

sub usage {
    print qq~ Parameters for the Socks5 plugin:
 -u <username>
 -v <password>
~;
}

1;