Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
RedToor committed Dec 23, 2016
1 parent decd2c9 commit 4bc1f84
Show file tree
Hide file tree
Showing 44 changed files with 13,878 additions and 33 deletions.
4 changes: 4 additions & 0 deletions LINETIME
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* 23/12/16
Added New Dependence : bs4, html parsing.
improvement in the function Global variables

* 21/12/16
Added New Banner : Chapecoense commemoration
Added New Function : isPortLive, check port services.
Expand Down
70 changes: 63 additions & 7 deletions core/Function.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#HEAD#########################################################
#
# Katana Framework | Function
# Last Modified: 21/12/2016
# Last Modified: 23/12/2016
#
#########################################################HEAD#

Expand Down Expand Up @@ -182,18 +182,36 @@ def ShowFullOptions(Options):
print Options.aux
except:b=0

### VARIABLES TEMP ###
### GLOBALS VARIABLES ###
def SaveValue(secuence):
try:
if secuence[len(SAVEV):len(SAVEV)+2]=="ip":
if secuence[len(SAVEV):len(SAVEV)+2].lower()=="ip":
nID = int(secuence[len(SAVEV)+3:])-1
grab = re.findall('([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)', KTFVAR[nID])
address = grab[0]
VARIABLESIP.append(address)
N=len(VARIABLESIP)
print " ---> variable Saved {"+colors[8]+"::IP"+str(N)+colors[0]+"} "+address

if secuence[len(SAVEV):len(SAVEV)+3]=="mac":
GlobalVariable("+","IP",address)
printAlert(3,"---> variable Saved {"+colors[8]+"::IP"+str(N)+colors[0]+"} "+address)

if secuence[len(SAVEV):len(SAVEV)+4].lower()=="list":
print " |-->VARIABLES IP"
index = 1
for value in VARIABLESIP:
print " | ::IP"+str(index)+" --> "+value
index+=1
print " |-->VARIABLES MAC"
index = 1
for value in VARIABLESMAC:
print " | ::MAC"+str(index)+" --> "+value
index+=1

if secuence[len(SAVEV):len(SAVEV)+3].lower()=="del":
if secuence[len(SAVEV)+4 : len(SAVEV)+6].upper() == "IP" : GlobalVariable("-", "IP", secuence[len(SAVEV)+6 : ])
if secuence[len(SAVEV)+4 : len(SAVEV)+7].upper() == "MAC" : GlobalVariable("-","MAC", secuence[len(SAVEV)+7 : ])
LoadGlobalVariables()

if secuence[len(SAVEV):len(SAVEV)+3].lower()=="mac":
nID = int(secuence[len(SAVEV)+4:])-1
p = re.compile(ur'([0-9a-f]{2}(?::[0-9a-f]{2}){5})', re.IGNORECASE)
address=re.findall(p, KTFVAR[nID])
Expand All @@ -203,8 +221,10 @@ def SaveValue(secuence):
address=address.replace("]","")
VARIABLESMAC.append(address)
N=len(VARIABLESMAC)
GlobalVariable("+","MAC",address)
printAlert(3,"---> variable Saved {"+colors[8]+"::MAC"+str(N)+colors[0]+"} "+address)
except:printAlert(6,"Check Again your Command for TEMP variables.")

except : printAlert(6,"Check Again your Command for Global variables.")

### PING ###
def isLive(defaulthost, defaultport):
Expand Down Expand Up @@ -862,5 +882,41 @@ def LoadSession(init):
except:extra=False
return init

### LOAD GLOBAL VARIABLES ###
def LoadGlobalVariables():

for value in VARIABLESIP:
VARIABLESIP.remove(value)

for value in VARIABLESMAC:
VARIABLESMAC.remove(value)

data_file = open('core/logs/variables.globals.json','r')
data_string = json.loads(data_file.read())

for value in data_string['variable_IP']:
VARIABLESIP.append(str(value))
for value in data_string['variable_MAC']:
VARIABLESMAC.append(str(value))

### ADD NEW GLOBAL VARIABLE ###
def GlobalVariable(action,typev,variable):
try:
with open('core/logs/variables.globals.json', 'r+') as jsond:
data = json.load(jsond)

if action == "+":
if typev == "IP" : data["variable_IP"].append(variable)
if typev == "MAC" : data["variable_MAC"].append(variable)

if action == "-":
if typev == "IP" : del data["variable_IP"][(int(variable) - 1)]
if typev == "MAC" : del data["variable_MAC"][(int(variable) - 1)]


jsond.seek(0)
jsond.write(json.dumps(data))
jsond.truncate()

except Exception as Error: printAlert(1,Error)

39 changes: 25 additions & 14 deletions core/Help.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
#HEAD#########################################################
#
# Katana Framework | Help File
# Last Modified: 21/12/2016
# Last Modified: 23/12/2016
#
#########################################################HEAD#

from GeneralCommands import *

def help():
print """
#General Commands
#General Commands.
[Command]\t\t[Quick Command]\t[Description]
"""+SHOW_MODULES+"""\t"""+SHOW_MODULES_SHORT+"""\t\t<--- Show modules
Expand All @@ -33,7 +33,7 @@ def help():
Version\t\t\t\t<--- Show Version framework
#Functions(f::)
#Functions(f::).
[Name]\t\t [Parameters]\t\t[Description]
get_aps()\t\t Interface, timeout\tScan Access point's
Expand All @@ -44,32 +44,43 @@ def help():
get_external_ip()\t None\t\t\tGet External IP
get_gateway()\t None\t\t\tGet Gateway/Router IP
##USE
##USE.
f::Functions(Parameters) <--> f::get_aps(mon0,10)
f::Functions <--> f::get_local_ip
#Save Result("""+SAVEV+""")
#Save Result("""+SAVEV+""").
if exist a output list in a module, you can save a item of list.
Elements |#| ip | mac | ...
item 0 [0] 127.0.0.1 | FF:FF:FF:FF:FF:FF | ...
item 1 [1] 10.10.1.1 | FF:FF:FF:FF:FF:FC | ...
##USE (Type of elements allowed.)
##USE (Type of elements allowed).
ip:{index} <--> """+SAVEV+"""ip:0 --> save <-- 127.0.0.1
mac:{index} <--> """+SAVEV+"""mac:1 --> save <-- FF:FF:FF:FF:FF:FC
|
Variable saved in ::{element}{index} <---------!
list <--> List Global variables
del:{element}:{index} <--> delete a Global variable
for invoke this variable saved.
set {parameter} ::{element}{index}
set target ::IP{index}
#Session
### Examples.
"""+SAVEV+"""ip:0
set target ::IP4
"""+SAVEV+"""list
"""+SAVEV+"""del:IP4
#Session.
"""+SESSION+""" -l <--> list sessions of module
"""+SESSION+""" -v {ID} <--> view a session
"""+SESSION+""" -i {ID} <--> Use a session
"""+SESSION+""" -d {ID} <--> Delete a session
"""+SESSION+""" -d {ID} <--> Delete a session , (*) for all
### Examples.
"""+SESSION+""" -v 3
"""+SESSION+""" -d *
#TODO
#TODO.
Please go to https://github.com/PowerScript/KatanaFramework
for more information go to doc folder.
"""
"""
7 changes: 5 additions & 2 deletions core/MainListLibrary.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#HEAD#########################################################
#
# Katana Framework
# Last Modified: 11/10/2016
# Last Modified: 13/12/2016
#
#########################################################HEAD#

Expand Down Expand Up @@ -31,4 +31,7 @@
SaveSession,
ListModules,
LoadSession,
SessionInterative)
SessionInterative,
LoadGlobalVariables)

import importlib
1 change: 1 addition & 0 deletions core/logs/variables.globals.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"variable_MAC": [], "variable_IP": []}
4 changes: 4 additions & 0 deletions dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ cd ..
cd ..
cd lib/libusb1/
sudo python setup.py install
cd ..
cd ..
cd lib/bs4/
sudo python setup.py install
12 changes: 6 additions & 6 deletions ktf.console
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
#HEAD#########################################################
#
# Katana Framework | ktf.console
# Last Modified: 21/12/2016
# Last Modified: 23/12/2016
#
#########################################################HEAD#

from core.MainListLibrary import *
from core import Banner , Errors
from core.GeneralCommands import *
from core import Banner , Errors
from core.Design import *
import importlib

def katanaFrameworkConsole():
try:
Expand Down Expand Up @@ -49,13 +48,14 @@ def katanaFrameworkConsole():
else:KatanaCheckActionGlobalCommands(actions)
except:Errors.Errors()
katanaFrameworkConsole()
elif KatanaCheckActionExefunction(action):Executefunction(action)
else :KatanaCheckActionGlobalCommands(action)
elif KatanaCheckActionExefunction(action) :Executefunction(action)
else :KatanaCheckActionGlobalCommands(action)
katanaFrameworkConsole()
except:Errors.Errors()
except :Errors.Errors()

if __name__=="__main__":

LoadBuffer()
LoadGlobalVariables()
Banner.LoadBanner()
katanaFrameworkConsole()
8 changes: 4 additions & 4 deletions ktf.run
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#HEAD#########################################################
#
# Katana Framework | ktf.run
# Last Modified: 20/10/2016
# Last Modified: 23/12/2016
#
#########################################################HEAD#

Expand All @@ -15,7 +15,7 @@ from core import Errors
import xml.etree.ElementTree as ET
import importlib,argparse,copy
LoadBuffer()

LoadGlobalVariables()
parser = argparse.ArgumentParser()
parser.add_argument("-m", "--module", help=" Script module to run.")
parser.add_argument("-q", "--quit" , action='store_false', default=True, help="No show Banner")
Expand Down Expand Up @@ -58,6 +58,6 @@ if __name__=="__main__":
ModuleToStart.main(True)
elif KatanaCheckActionisBack(actions) :printAlert(6,"This Commands just work in ktf.console mode.")
else :
if actions != "":KatanaCheckActionGlobalCommands(actions)
except:Errors.Errors()
if actions != "" :KatanaCheckActionGlobalCommands(actions)
except :Errors.Errors()
ModuleNotFound(args.module)
43 changes: 43 additions & 0 deletions lib/bs4/AUTHORS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Behold, mortal, the origins of Beautiful Soup...
================================================

Leonard Richardson is the primary programmer.

Aaron DeVore is awesome.

Mark Pilgrim provided the encoding detection code that forms the base
of UnicodeDammit.

Thomas Kluyver and Ezio Melotti finished the work of getting Beautiful
Soup 4 working under Python 3.

Simon Willison wrote soupselect, which was used to make Beautiful Soup
support CSS selectors.

Sam Ruby helped with a lot of edge cases.

Jonathan Ellis was awarded the prestigious Beau Potage D'Or for his
work in solving the nestable tags conundrum.

An incomplete list of people have contributed patches to Beautiful
Soup:

Istvan Albert, Andrew Lin, Anthony Baxter, Andrew Boyko, Tony Chang,
Zephyr Fang, Fuzzy, Roman Gaufman, Yoni Gilad, Richie Hindle, Peteris
Krumins, Kent Johnson, Ben Last, Robert Leftwich, Staffan Malmgren,
Ksenia Marasanova, JP Moins, Adam Monsen, John Nagle, "Jon", Ed
Oskiewicz, Greg Phillips, Giles Radford, Arthur Rudolph, Marko
Samastur, Jouni Sepp�nen, Alexander Schmolck, Andy Theyers, Glyn
Webster, Paul Wright, Danny Yoo

An incomplete list of people who made suggestions or found bugs or
found ways to break Beautiful Soup:

Hanno B�ck, Matteo Bertini, Chris Curvey, Simon Cusack, Bruce Eckel,
Matt Ernst, Michael Foord, Tom Harris, Bill de hOra, Donald Howes,
Matt Patterson, Scott Roberts, Steve Strassmann, Mike Williams,
warchild at redho dot com, Sami Kuisma, Carlos Rocha, Bob Hutchison,
Joren Mc, Michal Migurski, John Kleven, Tim Heaney, Tripp Lilley, Ed
Summers, Dennis Sutch, Chris Smith, Aaron Sweep^W Swartz, Stuart
Turner, Greg Edwards, Kevin J Kalupson, Nikos Kouremenos, Artur de
Sousa Rocha, Yichun Wei, Per Vognsen
27 changes: 27 additions & 0 deletions lib/bs4/COPYING.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Beautiful Soup is made available under the MIT license:

Copyright (c) 2004-2016 Leonard Richardson

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Beautiful Soup incorporates code from the html5lib library, which is
also made available under the MIT license. Copyright (c) 2006-2013
James Graham and other contributors
9 changes: 9 additions & 0 deletions lib/bs4/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include test-all-versions
include convert-py3k
include *.txt
include doc*/Makefile
include doc*/source/*.py
include doc*/source/*.rst
include doc*/source/*.jpg
include scripts/*.py
include scripts/*.txt
Loading

0 comments on commit 4bc1f84

Please sign in to comment.