-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmacspoofer.cmd
712 lines (553 loc) · 15.2 KB
/
macspoofer.cmd
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
@echo off
title Batch Spoofer 1.2.0 - Developed By TechnicalUserX
cls
set interface_admin_state=Not Selected
set interface_registry_location=Not Selected
set interface_description=Not Selected
set interface_id=Not Selected
set interface_mac=Not Selected
set interface_state=notdefined
setlocal enabledelayedexpansion
mode con:cols=100 lines=30
set program_directory=%~dp0
set program_drive=!program_directory:~0,2!
%program_drive%
cd "%program_directory%"
:check_Permissions
net session >nul 2>&1
if %errorLevel% == 0 (
set privilege_level=administrator
cd !current_directory!
cd BF_Files
del attempt.xml >nul
del infogate.xml >nul
cls
)else (
set privilege_level=local
cd BF_Files
del attempt.xml >nul
del infogate.xml >nul
cls
)
if %privilege_level% neq administrator (
echo.
call :color_echo . red " Administrator Privileges required to use this program..."
echo.
timeout /t 3 >nul
goto :exit_program
)
call :interface_detection
if !interface_number!==1 (
echo.
call :color_echo . cyan " Interface Detection"
echo.
echo.
call :color_echo . yellow " Only '1' Interface Found!"
echo.
echo.
call :color_echo . white " !interface_1_description!("
call :color_echo . magenta "!interface_1_mac!"
call :color_echo . white ")"
echo.
echo.
echo Making !interface_1_description! as default Interface...
set interface_id=!interface_1_id!
set interface_description=!interface_1_description!
set interface_mac=!interface_1_mac!
timeout /t 3 >nul
)
if !interface_number! gtr 1 (
echo.
call :color_echo . cyan " Interface Detection"
echo.
echo.
call :color_echo . yellow " Multiple '!interface_number!' Interfaces Found!"
echo.
timeout /t 3 >nul
call :interface_selection
)
if !interface_number!==0 (
echo.
call :color_echo . cyan " Interface Detection"
echo.
echo.
call :color_echo . yellow " WARNING"
echo.
echo No interfaces found on this device^^!
echo.
echo Press any key to continue...
timeout /t 5 >nul
cls
)
goto :interface_management
:interface_management
call :interface_admin_state_check
call :interface_mac_check
call :interface_registry_check
:skip_interface_management_check
cls
echo.
call :color_echo . cyan "Batch MAC Spoofer"
echo.
echo.
call :color_echo . cyan "Description: "
call :color_echo . yellow "!interface_description!
echo.
call :color_echo . cyan "MAC Address: "
call :color_echo . magenta "!interface_mac!"
echo.
call :color_echo . cyan "MAC Address Status: "
if "!interface_description!"=="Not Selected" (
call :color_echo . white "Not Selected"
goto :skip_mac_address_status_show
)
if "!interface_mac_changed!"=="true" (
call :color_echo . red "Changed"
)
if !interface_mac_changed!==false (
call :color_echo . green "Original Static Address"
)
:skip_mac_address_status_show
echo.
call :color_echo . cyan "ID: "
call :color_echo . white "!interface_id!"
echo.
call :color_echo . cyan "Interface Status: "
if "!interface_description!"=="Not Selected" (
call :color_echo . white "Not Selected"
)
if !interface_admin_state!==Enabled (
call :color_echo . green "Enabled"
)
if !interface_admin_state!==Disabled (
call :color_echo . red "Disabled"
)
echo.
echo.
echo.
call :color_echo . cyan "Interafe Management Commands"
echo.
echo.
echo - select : Choose another interface
echo - macspoof : Perform MAC Spoofing (Administrator Privileges)
echo - exit : Exits Interface Management
echo.
echo.
call :userinput
set /p interfacemanagementchoice=
if "!interfacemanagementchoice!"=="exit" (
exit
)
if "!interfacemanagementchoice!"=="select" (
call :interface_detection
call :interface_selection
cls
set interfacemanagementchoice=
goto :interface_management
)
if "!interfacemanagementchoice!"=="macspoof" (
if "!interface_description!"=="Not Selected" (
echo.
call :color_echo . red " An Interface must be selected for MAC Spoofing..."
timeout /t 3 >nul
set interfacemanagementchoice=
cls
goto :skip_interface_management_check
)
call :mac_spoofing
set interfacemanagementchoice=
cls
goto :skip_interface_management_check
)
call :color_echo . red " Invalid input"
echo.
timeout /t 2 >nul
cls
set interfacemanagementchoice=
goto :skip_interface_management_check
:mac_spoofing
if "!privilege_level!"=="local" (
echo.
call :color_echo . red " Administrator Privileges required to use this feature..."
timeout /t 3 >nul
cls
set interfacemanagementchoice=
goto :skip_interface_management_check
)
cls
echo.
call :color_echo . cyan " MAC Spoofing"
echo.
echo.
call :color_echo . cyan " Interface: "
call :color_echo . yellow "!interface_description!"
echo.
call :color_echo . cyan " MAC: "
call :color_echo . yellow "!interface_mac!"
echo.
echo.
call :color_echo . cyan " MAC Spoofing Commands"
echo.
echo.
echo - revert : Revert MAC address to original
echo - randomize mac : Randomize MAC Address
echo - define mac : Set MAC Manually
echo - exit : Exit MAC Spoofing screen
echo.
echo.
call :userinput
set /p macspoofingchoice=
if "!macspoofingchoice!"=="exit" (
set macspoofingchoice=
cls
goto :eof
)
if "!macspoofingchoice!"=="revert" (
if !interface_mac_changed!==false (
echo.
call :color_echo . red " !interface_description! is already has Original Static MAC..."
timeout /t 3 >nul
set macspoofingchoice=
cls
goto :mac_spoofing
)
echo.
echo Disabling "!interface_description!"...
netsh interface set interface name="!interface_id!" admin=disabled >nul
echo Reverting MAC Address...
reg delete !interface_registry_location! /v NetworkAddress /f >nul
echo Enabling "!interface_description!"...
netsh interface set interface name="!interface_id!" admin=enabled >nul
call :color_echo . green " Completed"
timeout /t 3 >nul
set macspoofingchoice=
cls
goto :interface_management
)
if "!macspoofingchoice!"=="define mac" (
set allowed_mac_char_list_obliged=EA26
set allowed_mac_char_list=0123456789ABCDEF
cls
echo.
echo Type the MAC without semicolons
echo.
call :color_echo . white " Example format: "
call :color_echo . green "AABBCCDDEEFF"
echo.
call :color_echo . yellow " WARNING: Second character of the MAC should be one of these {E, A, 2, 6 }
echo.
call :color_echo . red " This is a Windows restriction"
echo.
echo.
call :userinput
set /p manual_mac=
call :create_string manual_mac_check "!manual_mac!"
if !manual_mac_check_length! neq 12 (
call :color_echo . red " Length of a MAC must be 12 characters."
timeout /t 3 >nul
set macspoofingchoice=
cls
goto :interface_management
)
for /l %%a in ( 0, 1, 11) do (
if "%%a" == "1" (
if "!manual_mac_check:~%%a,1!" neq "E" if "!manual_mac_check:~%%a,1!" neq "e" if "!manual_mac_check:~%%a,1!" neq "A" if "!manual_mac_check:~%%a,1!" neq "a" if "!manual_mac_check:~%%a,1!" neq "6" if "!manual_mac_check:~%%a,1!" neq "2" (
call :color_echo . red " Second character is not matching the criteria, please use E, A, 2, or 6
timeout /t 3 >nul
set macspoofingchoice=
cls
goto :interface_management
)
)
call :validate_mac_char "!manual_mac_check:~%%a,1!"
if "!valid!" == "false" (
call :color_echo . red " Invalid character has been used"
timeout /t 3 >nul
set macspoofingchoice=
cls
goto :interface_management
)
)
echo.
call :color_echo . white " Defined MAC: "
call :color_echo . green "!manual_mac!"
echo.
echo.
echo Disabling "!interface_description!"...
netsh interface set interface name="!interface_id!" admin=disabled >nul
echo Applying new MAC Address...
reg add !interface_registry_location! /v NetworkAddress /t REG_SZ /d "!manual_mac!" /f
echo Enabling "!interface_description!"...
netsh interface set interface name="!interface_id!" admin=enabled >nul
call :color_echo . green " Completed"
timeout /t 3 >nul
set macspoofingchoice=
cls
goto :interface_management
)
if "!macspoofingchoice!"=="randomize mac" (
echo.
echo Generating a random MAC Address...
call :mac_randomizer
echo.
call :color_echo . white " Generated: "
call :color_echo . green "!set_mac!"
echo.
echo Disabling "!interface_description!"...
netsh interface set interface name="!interface_id!" admin=disabled >nul
echo Applying new MAC Address...
reg add !interface_registry_location! /v NetworkAddress /t REG_SZ /d "!set_mac!" /f
echo Enabling "!interface_description!"...
netsh interface set interface name="!interface_id!" admin=enabled >nul
call :color_echo . green " Completed"
timeout /t 3 >nul
set macspoofingchoice=
cls
goto :interface_management
)
echo.
call :color_echo . red " Invalid input"
echo.
timeout /t 2 >nul
set macspoofingchoice=
cls
goto :mac_spoofing
:interface_selection
call :interface_detection
set interface_choice=
del interfacelist.txt 2>nul
cls
echo.
set temp_interface_num_for_selection=1
call :color_echo . cyan " Interface Selection"
echo.
echo.
for /l %%a in ( 1, 1, !interface_number! ) do (
call :color_echo . yellow " !temp_interface_num_for_selection! - "
call :color_echo . white "!interface_%%a_description!("
call :color_echo . magenta "!interface_%%a_mac!"
call :color_echo . white ")"
echo.
echo !temp_interface_num_for_selection! - !interface_%%a_description! - !interface_%%a_mac!>>interfacelist.txt
set /a temp_interface_num_for_selection=!temp_interface_num_for_selection!+1
)
call :color_echo . red " !temp_interface_num_for_selection! - "
call :color_echo . white "Cancel Selection"
echo.
echo !temp_interface_num_for_selection! - Cancel Selection>>interfacelist.txt
set choice_cancel=!temp_interface_num_for_selection!
echo.
call :userinput
set /p interface_choice=
if !interface_choice!==!choice_cancel! (
goto :eof
)
if !interface_choice! gtr !interface_number! (
call :color_echo . red " Invalid input"
echo.
timeout /t 2 >nul
cls
set interface_choice=
goto :interface_selection
)
if !interface_choice! lss 1 (
call :color_echo . red " Invalid input"
echo.
timeout /t 2 >nul
cls
set interface_choice=
goto :interface_selection
)
for /f "tokens=1-3" %%a in ( interfacelist.txt ) do (
if !interface_choice!==%%a (
echo.
echo.
set interface_id=!interface_%%a_id!
set interface_description=!interface_%%a_description!
set interface_mac=!interface_%%a_mac!
set targetwifi=No WI-FI Selected
call :color_echo . white " Setting "
call :color_echo . yellow "!interface_description! "
call :color_echo . /f " as current interface..."
timeout /t 3 >nul
)
)
cls
del interfacelist.txt
goto :eof
:interface_detection
set interface_number=0
for /f "tokens=1-4" %%a in ('netsh wlan show interfaces ^| findstr /L "Name Description Physical"') do (
if "%%c"=="Wi-Fi" (
if "%%d"=="" (
set /a interface_number=!interface_number!+1
set interface_!interface_number!_id=%%c
)else (
set /a interface_number=!interface_number!+1
set interface_!interface_number!_id=%%c %%d
)
)
if %%a==Description (
set interface_!interface_number!_description=%%c %%d
)
if %%a==Physical (
set interface_!interface_number!_mac=%%d
)
)
goto :eof
:interface_admin_state_check
for /f "tokens=1-5" %%a in ( ' netsh interface show interface name^="!interface_id!" ' ) do (
if %%a==Administrative (
set interface_admin_state=%%c
goto :eof
)
)
goto :eof
:interface_mac_check
for /f "tokens=1-4" %%a in ( 'wmic nic get name^,macaddress ^| findstr /L "!interface_description!"') do (
if "!interface_description!"=="%%b %%c" (
set interface_mac=%%a
goto :eof
)
)
goto :eof
:interface_registry_check
for /f "tokens=* skip=8" %%a in ( 'REG QUERY HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}' ) do (
set current_registry_key=%%a
set current_registry_interface_description=
set interface_mac_changed=false
for /f "tokens=1-10" %%b in ( 'REG QUERY !current_registry_key! 2^>nul' ) do (
if %%b==DriverDesc (
set current_registry_interface_description=%%d %%e
)
if %%b==NetworkAddress (
set interface_mac_changed=true
)
)
if "!interface_description!" equ "!current_registry_interface_description!" (
set interface_registry_location=!current_registry_key!
goto :eof
)
)
goto :eof
:userinput
call :color_echo . green " macspoofer"
call :color_echo . white "$ "
goto :eof
:mac_randomizer
set allowed_mac_char_list_obliged=EA26
set allowed_mac_char_list=0123456789ABCDEF
set set_mac=
for /l %%a in ( 1,1,12) do (
if %%a==2 (
call :index_for_mac_calc_2
call :set_mac_char_2 !index_for_mac!
)else (
call :index_for_mac_calc_1
call :set_mac_char_1 !index_for_mac!
)
)
goto :eof
:index_for_mac_calc_1
set /a index_for_mac=(!random!) %% 16
goto :eof
:set_mac_char_1
set set_mac=!set_mac!!allowed_mac_char_list:~%1,1!
goto :eof
:index_for_mac_calc_2
set /a index_for_mac=(!random!) %% 4
goto :eof
:set_mac_char_2
set set_mac=!set_mac!!allowed_mac_char_list_obliged:~%1,1!
goto :eof
:create_string
set /a takeaway=4
set string=%2
echo !string!>var.txt
for /f "useback tokens=*" %%a in ( '%string%' ) do (
if !string!==%%~a (
set /a takeaway=2
)
set string=%%~a
)
set %1=!string!
for %%I in ( var.txt ) do (
set /a %1_length=%%~zI - !takeaway!
)
del var.txt
goto :eof
:validate_mac_char
set allowed_mac_char_list_obliged_extended=EA26ea
set allowed_mac_char_list_extended=0123456789ABCDEFabcdef
set valid=false
for /l %%a in ( 0, 1, 21) do (
if "%~1" == "!allowed_mac_char_list_extended:~%%a,1!" (
set valid=true
goto :eof
)
)
goto :eof
:color_echo
:: Check if the first 2 arguments are empty, cause they are needed for background/foreground information
:: The 3rd argument is not that important because it can be an empty string
if "%~1" equ "" (
goto :eof
)
if "%~2" equ "" (
goto :eof
)
:: Background color; if invalid, no action
if "%~1" equ "black" (
<nul set /p=[40m
)
if "%~1" equ "red" (
<nul set /p=[41m
)
if "%~1" equ "green" (
<nul set /p=[42m
)
if "%~1" equ "yellow" (
<nul set /p=[43m
)
if "%~1" equ "blue" (
<nul set /p=[44m
)
if "%~1" equ "magenta" (
<nul set /p=[45m
)
if "%~1" equ "cyan" (
<nul set /p=[46m
)
if "%~1" equ "white" (
<nul set /p=[47m
)
:: Foreground color; if invalid, no action
if "%~2" equ "black" (
<nul set /p=[30m
)
if "%~2" equ "red" (
<nul set /p=[31m
)
if "%~2" equ "green" (
<nul set /p=[32m
)
if "%~2" equ "yellow" (
<nul set /p=[33m
)
if "%~2" equ "blue" (
<nul set /p=[34m
)
if "%~2" equ "magenta" (
<nul set /p=[35m
)
if "%~2" equ "cyan" (
<nul set /p=[36m
)
if "%~2" equ "white" (
<nul set /p=[37m
)
<nul set /p="%~3" <nul
<nul set /p=[0m
goto :eof
:exit_program
goto :eof