line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SwitchMac; |
2
|
1
|
|
|
1
|
|
24214
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
BEGIN { |
5
|
1
|
|
|
1
|
|
6
|
use Exporter (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
6
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
120
|
|
7
|
1
|
|
|
1
|
|
2
|
$VERSION = '0.01'; |
8
|
1
|
|
|
|
|
16
|
@ISA = qw(Exporter); |
9
|
|
|
|
|
|
|
#Give a hoot don't pollute, do not export more than needed by default |
10
|
1
|
|
|
|
|
2
|
@EXPORT = qw(); |
11
|
1
|
|
|
|
|
2
|
@EXPORT_OK = qw(); |
12
|
1
|
|
|
|
|
404
|
%EXPORT_TAGS = (); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#################### subroutine header begin #################### |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head2 setMac |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Usage : setMac($macaddress,$adapter_name); |
21
|
|
|
|
|
|
|
Purpose : Set a new mac address to a specific adapter |
22
|
|
|
|
|
|
|
Argument : $macaddress, $adapter_name |
23
|
|
|
|
|
|
|
Comment : This function will set a new address specified |
24
|
|
|
|
|
|
|
: to a specific mac address |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#################### subroutine header end #################### |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub setMac |
31
|
|
|
|
|
|
|
{ |
32
|
0
|
|
|
0
|
|
|
my($macaddress,$adapter_name)=@_; |
33
|
0
|
|
|
|
|
|
system("sudo ifconfig $adapter_name down"); |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
system("sudo ifconfig $adapter_name hw ether $macaddress"); |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
system("sudo ifconfig $adapter_name up"); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
#################### subroutine header begin #################### |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 setMac |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Usage : setMacList($listMAC_file_name,$adapter_name, |
45
|
|
|
|
|
|
|
: $frequency,$setTime); |
46
|
|
|
|
|
|
|
Purpose : Set a new mac address based on the list to a |
47
|
|
|
|
|
|
|
: specific adapter with time and frequency |
48
|
|
|
|
|
|
|
: switch |
49
|
|
|
|
|
|
|
Argument : $macaddress, $adapter_name, $frequency, $setTime |
50
|
|
|
|
|
|
|
Comment : This function will set a new address specified on |
51
|
|
|
|
|
|
|
: the list to a specific mac address with frequency |
52
|
|
|
|
|
|
|
: and time change. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Example : setMacList(listMac.txt,wlan0,10,60) |
55
|
|
|
|
|
|
|
: |
56
|
|
|
|
|
|
|
: Here the mac will changes 10 times after 60 seconds |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
#################### subroutine header end #################### |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub setMacList |
63
|
|
|
|
|
|
|
{ |
64
|
|
|
|
|
|
|
my($listMAC_file_name,$adapter_name,$frequency,$setTime)=@_; |
65
|
|
|
|
|
|
|
my@list; |
66
|
|
|
|
|
|
|
unless(open(FILE,"<$list_file_name")){ |
67
|
|
|
|
|
|
|
die "Erro ao abrir arquivo para leitura!"; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
while(){ |
71
|
|
|
|
|
|
|
$_ =~ s/\n//g; |
72
|
|
|
|
|
|
|
push(@list,$_); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
srand(time^$$); |
76
|
|
|
|
|
|
|
my$MACFake = $list[rand($#list)]; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
system("sudo ifconfig $adapter_name down"); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
system("sudo ifconfig $adapter_name hw ether $MACFake"); |
81
|
|
|
|
|
|
|
print "New Faked MAC: $MACFake\n"; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
print "\n"; |
84
|
|
|
|
|
|
|
system("sudo ifconfig $adapter_name up"); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
for(my$x=0; $x<= ($frequency-2); $x++){ |
87
|
|
|
|
|
|
|
if($setTime != 0){ |
88
|
|
|
|
|
|
|
sleep($setTime); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
else{ |
91
|
|
|
|
|
|
|
sleep(1); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
system"setMac($list_file_name $adapter_name)"; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
#################### main pod documentation begin ################### |
100
|
|
|
|
|
|
|
## Below is the stub of documentation for your module. |
101
|
|
|
|
|
|
|
## You better edit it! |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 NAME |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
SwitchMac - provide tools to change the mac address |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 SYNOPSIS |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
use SwitchMac; |
111
|
|
|
|
|
|
|
blah blah blah |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 DESCRIPTION |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Stub documentation for this module was created by ExtUtils::ModuleMaker. |
117
|
|
|
|
|
|
|
It looks like the author of the extension was negligent enough |
118
|
|
|
|
|
|
|
to leave the stub unedited. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Blah blah blah. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 USAGE |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 BUGS |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 SUPPORT |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 AUTHOR |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Rafael Lucas |
138
|
|
|
|
|
|
|
CPAN ID: RAFALUCAS |
139
|
|
|
|
|
|
|
rafalucas@cpan.org |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 COPYRIGHT |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This program is free software; you can redistribute |
144
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
The full text of the license can be found in the |
147
|
|
|
|
|
|
|
LICENSE file included with this module. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 SEE ALSO |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
perl(1). |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
#################### main pod documentation end ################### |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
1; |
160
|
|
|
|
|
|
|
# The preceding line will help the module return a true value |
161
|
|
|
|
|
|
|
|