用telnet傳輸文件

用telnet傳輸文件

解決libcrypto.so.1.0.1e丟失致使ssh連不上

libcrypto.so.1.0.1e丟失,ssh連不上,並且wget,yum,scp等等命令都無法使用了,這時候該怎麼辦呢,能夠利用telnet來進行文件傳輸。分下面兩步驟python

1、用python建立個臨時服務器,發送文件供telnet訪問

import socket
import base64
port     = 10005
filename = 'libcrypto.so.1.0.1e'

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('0.0.0.0', port))
sock.listen(5)
while True:
    connection,address = sock.accept()
    try:
        content = 'hello'
        f = file(filename)
        content = base64.b64encode(f.read())
        connection.sendall(content.strip())
        connection.close()
    except socket.timeout:
        print 'time out'
    connection.close()

2、依次執行下面命令

telnet 102.200.200.202 10005 |tee > temp.txt
tail -n +4 temp.txt > temp2.txt
base64 -d < temp2.txt |tee >libcrypto.so.1.0.1e.so

上面的ip地址是個例子瞎寫的。記得換成你本身的哦。服務器

原理說明

只有telnet能與外界通訊,那麼能夠把文件轉成文本形式輸出到telnet端,再寫入文件 最後反解回二進制。 二進制轉文本用base64你們應該都知道就很少說了。ssh

相關文章
相關標籤/搜索