from machine import Pin, I2C
import network
import ssd1306
import random
import urandom
from time import sleep
'''code names
1.0 - first version
1.1 wolfspider - http c2 server
falcon - monitor mgmt mode frame attacks
pittviper - infared communications (replay, blaster, control)
'''
ip = ""
# ESP32 Pin assignment
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
#oled
oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)
button_pin1 = Pin(27, Pin.IN, Pin.PULL_UP) # green button (side)
button_pin2 = Pin(14, Pin.IN, Pin.PULL_UP) # red button (trig)
pintwelve = Pin(12, Pin.OUT)
pinthirteen = Pin(13, Pin.OUT)
pintwelve.value(1)
pinthirteen.value(1)
def generate_password():
return ''.join(
chr(urandom.getrandbits(7) % 26 + 97) # Random lowercase letter
for _ in range(urandom.getrandbits(3) % 3 + 4) # 4-6 letters
) + ''.join(
chr(urandom.getrandbits(7) % 10 + 48) # Random digit
for _ in range(urandom.getrandbits(3) % 5 + 4) # 4-8 digits
)
password = generate_password()
def main_screen():
oled.fill(0)
oled.text('Advanced Module', 0, 10)
oled.text('System 1.0', 15, 20)
oled.show()
def setup_hotspot():
global ip
# Create an Access Point (AP)
ap = network.WLAN(network.AP_IF) # Create AP interface
ap.active(True) # Activate the interface
# Configure the AP
ssid = 'ESP32_Hotspot'
#password = '123456789' # Set your desired password
ap.config(essid=ssid, password=password)
# Print the IP address of the AP
ip = ap.ifconfig()[0]
print(f'Access Point IP address: {ip}')
def net_screen():
oled.fill(0)
oled.text('Advanced Module', 0, 1)
oled.text('System 1.0', 15, 11)
oled.text('IP: ' + ip, 0, 21)
oled.text('PW: ' + password, 0, 31)
oled.show()
###############################################################################
def function1():
print("Button 1 pressed!")
# Add your code for button 1 functionality here
def function2():
print("Button 2 pressed!")
# Add your code for button 2 functionality here
###############################################################################
def main():
print("main started")
while True:
# Read the state of the buttons
button_state1 = not button_pin1.value() # Button pressed (active-low)
button_state2 = not button_pin2.value() # Button pressed (active-low)
# Check if button 1 is pressed
if button_state1:
function1()
sleep(0.5) # Debounce delay
# Check if button 2 is pressed
elif button_state2:
function2()
sleep(0.5) # Debounce delay
def startup():
main_screen()
sleep(3)
setup_hotspot()
net_screen()
main()
startup()