AverageSecurityGuy

Security, Programming, Pentesting

About

Mastodon

Linked In

Projects

Cheat Sheets

Book

11 February 2011

Morse Code Ping

by {"login"=>"averagesecurityguy", "email"=>"stephen@averagesecurityguy.info", "display_name"=>"averagesecurityguy", "first_name"=>"", "last_name"=>""}

I saw this on twitter. So I made this. It uses the TTL on the ping packet to represent a '.', '-', or ' '. Don't know if this works but here it is.

import random
import os

code = {'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.',
        'F': '..-.', 'G': '--.', 'H': '....', 'I': '..', 'J': '.---',
        'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.', 'O': '---',
        'P': '.--.', 'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-',
        'U': '..-', 'V': '...-', 'W': '.--', 'X': '-..-', 'Y': '-.--',
        'Z': '--..', '0': '-----', '1': '.----', '2': '..---', '3': '...--',
        '4': '....-', '5': '.....', '6': '-....', '7': '--...', '8': '---..',
        '9': '----.', ',': '--..--', '.': '.-.-.-', ' ': ' ', '_': '..--.-',
        '?': '..--..', ';': '-.-.-.', ':': '---...', "'": '.----.',
        '-': '-....-', '/': '-..-.', '(': '-.--.-', ')': '-.--.-' }
    
def encode(s):
    mstr = ''
    for c in s:
        mstr += code[c]
    return mstr
   
def mstr2packets(d, mstr):
    """Send ICMP packet with ttl within certain range to represent a '.', '-',
    or ' '. ttl < 80 = '.', 80 < ttl < 160 = '-', 160 < ttl = ' ' """
    for c in mstr:
        if c == '.':
            t = random.randrange(24,80)
        elif c == '-':
            t = random.randrange(104,160)
        elif c == ' ':
            t = random.randrange(184,254)
        else:
            pass
        ping = 'ping -n 1 -i ' + str(t) + ' ' + d
        print ping
        os.system('ping -n 1 -i ' + str(t) + ' ' + d)
        
word = "a"
mstr = encode(word.upper())
dest = '192.168.170.1'
mstr2packets(dest, mstr)
tags: