Created
June 18, 2014 20:27
-
-
Save Demontager/340cbb413aecba500a6c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# Alfa AWUS036 power increase up-to 30dbm | |
from os import getuid, devnull | |
import argparse | |
from sys import argv | |
from subprocess import call | |
from sys import stdout, stdin | |
# Console colors | |
W = '\033[0m' # white (normal) | |
R = '\033[31m' # red | |
G = '\033[32m' # green | |
O = '\033[33m' # orange | |
B = '\033[34m' # blue | |
P = '\033[35m' # purple | |
C = '\033[36m' # cyan | |
GR = '\033[37m' # gray | |
global IFACE, args, POWER, MON, CH, DUMP | |
args = argv[1:] | |
IFACE = str(args[1:2]).strip('[]') | |
CH = str(args[2:3]).strip('[]') | |
print (CH) | |
POWER = '30dbm' | |
DN = open(devnull, 'w') | |
MON = str(call("iwconfig 2>/dev/null| awk '/^mon+/ {print $1}'", shell=True, stdout=DN, stderr=None, stdin=None)) | |
DUMP = '/tmp/dump.cap' | |
def msg(): | |
print(G+'txpower usage:' +GR+'[start/stop/all]'+W) | |
print(G+'Optional: ' +GR+'channel'+W) | |
if len(args) <= 3: | |
print (args) | |
else: | |
msg() | |
def check_iface(): | |
iface = call(['iwconfig', IFACE]) | |
if iface != 0: | |
exit(1) | |
x = getuid() | |
if x != 0: | |
print(G+'You have to be'+R+' root ' +G+'to run this script'+W) | |
exit(1) | |
def power(): | |
check_iface() | |
#if call("iwconfig IFACE|awk '/Access/{print $4}'", shell=True) == "Not-Associated" or call ("iwconfig IFACE|awk '/Access/{print $4}'", shell=True) == "": | |
#print('here') | |
power() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment