-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathgerix_config.py
175 lines (124 loc) · 2.91 KB
/
gerix_config.py
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
#!usr/bin/python
# == Configuration file for GerixWifiCracker-NG ==
#
# This script is used for configure your installation of GerixWifiCracker-NG
# Follow the comments for a correct configuration, and please don't modify
# undocumented lines.
#
# Using correctly this file, it's possible to automate repetitive tasks, and
# make the program much more powerful.
#
# After all, "everyone can use a tool, but professional is recognized by his
# configuration file".
#
# Don't modify these lines
#
import sys
import os
import time
import re
import commands
#import subprocess
#
# Program directories
#
#
# Home directory:
# home_dir = os.getenv('HOME')
#
home_dir = os.getenv('HOME')
#
# Config directory:
# config_dir = home_dir + '/.gerix-wifi-cracker/'
#
config_dir = str(home_dir )+ '/.gerix-wifi-cracker/'
#
# Default color terminal:
# def_term = 'xterm'
#
def_term = 'xterm'
#
# Key database
#
# Database path:
# database_path = config_dir + 'key-database.db';
database_path = config_dir + 'key-database.db';
#
# Other variables used by the program
#
selected_interface = ''
#
# Init and end function, called by the program.
#
# Very useful for automating tasks or commands (such as 'macchanger',
# 'ifconfig up', 'airmon-ng')
#
#
# Init function (called when the program starts)
#
def config_init():
#
# Example: Automatically prepare an interface
#
# 1) check if interface is present
# 2) change the mac address to a random one
# 3) enable monitor mode
# 4) select the interface
#
# intf = 'wlan0'
# if wifi_interface_is_present(intf):
# set_random_mac(intf)
# set_wifi_mode(intf, 'monitor')
# select_interface = intf
return 0
#
# End function (called when the program ends)
#
def config_end():
#
# Example: disable an interface
#
# intf = 'wlan0'
# if wifi_interface_is_present(intf):
# exec_command("ifconfig " + intf + " down")
#
return 0
#
# == CONFIGURATION ENDS HERE ==
#
#
# UTILITIES
# (Than you don't need to modify) ;)
#
#
# Execute a command
#
def exec_command(cmd):
return subprocess.getstatusoutput(cmd)[0]
#
# Check if a wireless interface is present
#
def wifi_interface_is_present(interface):
if exec_command('iwconfig 2>&1 | grep 802.11 | grep' + interface):
return True
return False
#
# Set random MAC address
#
def set_random_mac(interface):
if exec_command('ifconfig ' + interface + ' down') != 0:
return
if exec_command('macchanger --random ' + interface) != 0:
return
if exec_command('ifconfig ' + interface + ' up') !=0:
return
#
# Set wireless interface mode
#
def set_wifi_mode(interface, mode):
if exec_command('ifconfig ' + interface + ' down') != 0:
return
if exec_command('iwconfig ' + interface + ' mode ' + mode) != 0:
return
if exec_command('ifconfig ' + interface + ' up') != 0:
return