Example #1
0
	def ct(self, type='', aim='', count=10):
		"""
		Run context().
		Args:
			- context type(char): r, d, s
			- address(hex)/register(string): if you choose disassemble, you can input place where you want to see. (optional)
			- count(int): the number of instructions to disassemble. (optional)
		"""
		debugger = DebuggerAdaptor()
		if not type:
			debugger.context()
		elif type == 'r':
			debugger.context_register()
		elif type == 's':
			debugger.context_stack()
		elif type == 'd':
			try:
				if not aim:
					debugger.context_code()
				else:
					aim = self._get_aim(aim)
					text = debugger.disassemble_around(aim, int(count))
					cprint(format_disasm_code(text, aim))
			except:
				self._error_args()
		else:
			self._error_args()
Example #2
0
def print_banner():
    logo = r""" 
         _____ _                    _   _   _                       _
        |_   _| |__  _ __ ___  __ _| |_| | | | ___  _   _ _ __   __| |
          | | | '_ \| '__/ _ \/ _` | __| |_| |/ _ \| | | | '_ \ / _` |
          | | | | | | | |  __/ (_| | |_|  _  | (_) | |_| | | | | (_| |
          |_| |_| |_|_|  \___|\__,_|\__|_| |_|\___/ \__,_|_| |_|\__,_|
        """
    cprint_red(logo)
    cprint()
Example #3
0
 def inp():
     while True:
         message = input()
         if message.startswith('/ALLOW_EXEC'):
             global allow_exec
             if allow_exec != True:
                 allow_exec = True
                 cprint('yellow', '### EXEC WAS ALLOWED. BE CAREFUL. ###')
             else:
                 allow_exec = False
                 cprint('yellow', '### EXEC WAS DISABLED. ###')
         else:
             ws.send(message);
Example #4
0
	def context_code(self, pc='', count = 14):
		"""
		Display nearby disassembly at $PC of current execution context
		Usage:
			MYNAME [linecount]
		"""

		if not pc:
			pc = self.pc()[1]
		if self.is_address(pc):
			(func,inst) = self.get_disasm(pc)
		else:
			(func,inst) = (None, None)

		wprint("[%s]" % "disassemble".center(200, "-"),"lightblue","black",1)
		if inst: # valid $PC
			text = []
			opcode = inst.split("\t")[-1].split()[0].strip()

			# stopped at function call
			if "call" in opcode:
				text += self.disassemble_around(pc, count)
				cprint(format_disasm_code(text, pc))
				self.dumpargs()
			# stopped at jump
			elif "j" in opcode:
				jumpto = self.testjump(inst)
				if jumpto: # JUMP is taken
					text += self.disassemble_around(pc, count, 1)
					for i,k in enumerate(text):
						if k[0] == pc:
							break
					cprint(format_disasm_code(text[:i+1], pc))
					jtext = self.disassemble_around(jumpto, count-1, 0, 0)
					wprint("===> jump to\n","red")
					if not jtext:
						wprint("   Cannot evaluate jump destination\n","red")
					else:
						cprint(format_disasm_code(jtext, jumpto))
				else: # JUMP is NOT taken
					text += self.disassemble_around(pc, count, -1)
					cprint(format_disasm_code(text, pc))
			# stopped at other instructions
			else:
				text += self.disassemble_around(pc, count)
				cprint(format_disasm_code(text, pc))
		else: # invalid $PC
			wprint("Invalid $PC address: 0x%x" % pc, "red", "black", 1)

		return
Example #5
0
	def context_register(self,target_id=0):
		wprint("[%s]" % "registers".center(200, "-"),"lightblue","black",1)
		#text = ""
		def get_reg_text(r, v):
			text = green("%s" % r.upper().ljust(3)) + ": "
			chain = self.examine_mem_reference(v)
			text += format_reference_chain(chain)
			text += "\n" 
			return text 
		regs = self.registers()
		bits = self._target()['bits']
		text = ''
		for r in self.REGISTERS[bits]:
			if r in regs:
				text += (get_reg_text(r, regs[r]))
		cprint(text)
		return
Example #6
0
	def dumpargs(self, *arg):
		"""
		Display arguments passed to a function when stopped at a call instruction
		Usage:
			MYNAME [count]
				count: force to display "count args" instead of guessing
		"""

		(count,) = normalize_argv(arg, 1)

		args = self.get_function_args(count)
		if args:
			print("Guessed arguments:")
			for (i, a) in enumerate(args):
				chain = self.examine_mem_reference(a)
				cprint("arg[%d]: %s" % (i, format_reference_chain(chain))+"\n")
		else:
			print("No argument")

		return
Example #7
0
def pager(text, pagesize=12):
	"""
	Paging output, mimic external command less/more
	"""
	if pagesize <= 0:
		cprint(text)
		return

	i = 1
	text = text.splitlines()
	l = len(text)

	for line in text:
		cprint(line+"\n")
		if i % pagesize == 0:
			ans = input("--More--(%d/%d)" % (i, l))
			if ans.lower().strip() == "q":
				break
		i += 1

	return
Example #8
0
def on_open(ws):
    cprint("green", "### Connected to chat. ###")
    def run(*args):
        while True:
            time.sleep(1)
        time.sleep(1)
        ws.close()
    thread.start_new_thread(run, ())
    def inp():
        while True:
            message = input()
            if message.startswith('/ALLOW_EXEC'):
                global allow_exec
                if allow_exec != True:
                    allow_exec = True
                    cprint('yellow', '### EXEC WAS ALLOWED. BE CAREFUL. ###')
                else:
                    allow_exec = False
                    cprint('yellow', '### EXEC WAS DISABLED. ###')
            else:
                ws.send(message);
    thread.start_new_thread(inp, ())
Example #9
0
def on_close(ws):
    cprint("red", "### Disconnected from chat. ###")
Example #10
0
# RUN IN POWERSHELL

from color import cprint
import websocket
import json as JSON
import math as Math
import os

ws = websocket.WebSocket()
cprint('purple', 'Welcome to ConsoleChat! Select your name and room or use default values! (CTRL+C & Enter to exit). Author: dimden (Eff the cops#1877)')
nick = input("Select name (Unnamed): ")
room = input("Select room (main): ")

global allow_exec
allow_exec = False
origin = "https://webchat.glitch.me"

try:
    import thread
except ImportError:
    import _thread as thread
import time

def on_message(ws, message):
    global allow_exec
    if JSON.loads(message)[2].startswith('!EXEC') and allow_exec:
        msg = JSON.loads(message)[2].split(" ") # Беру сообщение, и делаю с него массив
        msg.pop(0) # Вырезаю первое сообщение (так надо)
        msg = " ".join(msg) # Склеиваю массив назад в строку уже без первого сообщения
        print(JSON.loads(message)[1], ": ", msg) # Консолю
        os.system(msg) # Выполняю