_socketobject'对象没有属性'bing'

时间:2017-03-23 09:15:20

标签: python

首先,我想说我是python的新手我主要用来在java中编程,所以请原谅我,如果答案很明显但是我有错误(_socketobject'对象没有属性'bing')当我运行我的脚本时但我看不出它有什么问题......

import socket
import sys
import threading
import paramiko

  host_key = paramiko.RSAKey 
  (filename='/home/moonman/Desktop/test_rsa.key')


  class Server (paramiko.ServerInterface):

def __init__(self):
    self.event = threading.Event()

def check_channel_request(self, kind, chanid):
    if kind == 'session':
        return paramiko.OPEN_SUCCEEDED
    return paramiko.OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED

def check_auth_password(self, username, password):
    if (username == 'moonman') and (password == 'lover23567'):
        return paramiko.AUTH_SUCCESSFUL
    return paramiko.AUTH_FAILED

try:
     global sock
     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     sock.bing(('192.168.1.13' , 22))
     sock.listen(1)
     print '[+] Listening for Connection ...' 


except Exception, e:
print '[-] Cant start listening ): ' + str(e)

try:
     client, addr = sock.accept()
     print '[+] Just got a reverse connection from ' + str(addr)
     t = paramiko.Transport(client)
     t.load_server_moduli()
     t.add_server_key(host_key)
     server = Server()
     t.start_server(server=server)
     global chan
     chan = t.accept(1)
     print chan.recv(1024)
     chan.send("Connection Understood! Loud and clear!!")

except:
print "[-] Connection just died"
pass

1 个答案:

答案 0 :(得分:1)

套接字对象没有bing属性。我想你的意思是sock.bind将套接字绑定到你定义的地址。 试试这个:     

sock.bind((' 192.168.1.13',22))