Socket

Server

import socket

HOST = ‘localhost’
PORT = 1337

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)

conn, addr = s.accept()
print ‘Connected by’, addr

while 1:
data = conn.recv(1024)
if not data:break
print(data)
conn.send(data)

conn.close()

Client

import socket

HOST = ‘localhost’
PORT = 1337

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))

string1 = raw_input(‘pls enter something:’)
s.send(string1)
data = s.recv(1024)

s.close()
print ‘Received’, repr(data)

Enable ssh on OS X

The Apple Mac OS X operating system has SSH installed by default
but the SSH daemon is not enabled. This means you can’t login
remotely or do remote copies until you enable it.

To enable it, go to ‘System Preferences’. Under ‘Internet & Networking’
there is a ‘Sharing’ icon. Run that. In the list that appears, check the
‘Remote Login’ option.

This starts the SSH daemon immediately and you can remotely login using
your username. The ‘Sharing’ window shows at the bottom the name and IP
address to use. You can also find this out using ‘whoami’ and ‘ifconfig’
from the Terminal application.

so you can scp file like this on Kali Linux
scp Socket* like@192.168.1.110:~

文章目录
  1. 1. Server
  2. 2. Client
  3. 3. Enable ssh on OS X
,