r/AskProgramming • u/grpagrati • May 12 '20
Could aliens reverse engineer TCP/IP?
Sorry for the off-the-wall question. It's for a story I'm writing. The aliens are about as advanced as we were the 50s. They know English but don't know our protocols, algorithms, etc. They receive a stream of data in TCP/IP format. How difficult would it be for them to make sense of it and decode it?
Edit: Thank you very much to everyone who answered!
23
u/reddilada May 12 '20
They have figured out English, so given that I'm going to say sure. Packets have lots of repetition, especially in the header, so I'm going to say our alien sock hoppers are up for the challenge.
17
u/wrosecrans May 12 '20
I'm more optimistic than some of the others. I think it would be pretty straightforward to pick apart enough of a TCP connection to have some idea what's going on. How exactly they get the stream will make a difference. If they pick up wifi signals from an orbiting human spaceship, I think that would be impossible. The signaling rate is very high to try to pick anything out with 50's electronics, and there is a lot of channel hopping RF weirdness to something like WIFI. They might detect a small amount of static noise, but they wouldn't be able to identify a signal. But assuming they had a log of 1's and 0's and didn't have to pick apart the physical layer, they'd probably be able to get something out of it. Since the premise is whether aliens can figure out TCP, and not whether they can figure out Wifi (or Ethernet)...
https://en.wikipedia.org/wiki/Transmission_Control_Protocol#TCP_segment_structure shows the header format.
The source and destination port are constant for a single transaction, so you don't need to understand it deeply if you've already got a single TCP conversation to examine. The binary encoding is straightforward, and if they have a lot of examples to dig through, they'd probably figure out that dest port = 80 is unencrypted because the payloads have patterns, and dest port = 443 is encrypted because of basic frequency analysis. That would suggest they should focus their efforts on stuff where the conversation starts with the second 16 bits having that value.
Things like the exact checksum algorithm -- I'd guess their top mathematicians could figure that out, but it's not necessary for reading the stream. You only need that for sending data that is valid, or validating possibly corrupt data. For general reverse engineering, you can skip it.
The SYN ACK SYNACK pattern is 100% consistent when creating a connection, and had obvious bits set, so that part would be pretty straightforward to figure out. Especially if you've got some ability to steal a piece of human gear and cause it to try to connect to things on command to generate arbitrary amounts of test data. The general length of the headers vs. the payload would also be pretty easy to figure out if you've got enough example packets to study. When downloading plain text, the values after the header range are always constrained to a certain range of valid/normal printable ASCII characters. And you could differentiate probably text downloads from larger binary downloads based on the length of the TCP conversation - an MP4 file download will be many more packets, and with 1950's computers being used for the analysis, you'd work on short complete streams first.
Figuring out that we use 8 bits as the basic unit of data transmission would probably be a bit of a guess at first. There's no reason it has to be true. But it's a fairly small number, a convenient power of two, etc. So it makes sense that they'd figure out byte alignment fairly early after trying 5/6/7/9 bit alignments for interpreting the data and finding that conversation bit length % 8 is always 0. Again, that depends on having multiple examples to look at because any given stream could have an even number of bytes if you tried to assume it had 5 bit bytes.
Since I think you could get a decent estimate for the boundary of the header vs the payload when downloading plaintext, it's probably that they could figure out the data offset field from those streams, and then use that to pull payloads out of non-ascii downloads as well.
So, a few fields would be WTF's. HTTPS would be a lost cause. Figuring out what is in an MP4 file would exceed their compute capacity. But the bare minimum of TCP traffic analysis is probably possible. They could probably do stuff like read email on port 25 if they had a way to capture the packets. Once they know it is text, and they know English already, figuring out enough ASCII to read most plain text is a simple Caesar cipher. Kids could almost figure out that for fun. It helps if they know that the name of their own planet is likely to be in the text, or some stuff like that that can be helpful for guessing ASCII values. They might well get some of ASCII wrong. If the corpus they use for reverse engineering is all written by a jackass who constantly types IN ALL CAPS! Or ends every! sentence! with an exclamation Point! They might mix up . and ! or mix up upper case and lower case. But they'd plausibly be able to get far enough to get the gist of it.
If saving their alien planet depends on connecting to human hardware and speaking the full protocol, rather than merely being able to get some useful information out of it, you need to master sequence numbers and checksums and acks. That's harder. Not necessarily impossible, but sort of a EUREKA moment in the bath tub while smoking a pipe for some parts of it. I can easily believe them never getting it after years of work. I can also believe the Bletchly park team that figured out Enigma in the 40's looking over some papers for five minutes and spotting patterns immediately. But even the crazy geniuses that cracked Enigma had several years to build custom hardware at the very limits of the technology at the time. It wasn't just one all-nighter.
27
u/Northeastpaw May 12 '20
Not impossible but profoundly difficult. A big part of deciphering unknown data is having some guess as to what to look for. Assuming the payload was ASCII character data for English text the aliens might eventually figure out how a byte corresponds to a letter, but even that would be difficult because the first letter of the English alphabet 'A' is 01000001. An alien would eventually recognize that 0100 is some sort of prefix for letters, but it would be a stumbling block.
There's also a lot of data in the header of a TCP/IP packet. A lot of that header doesn't make much sense out of context. If you have no concept of an IPv6 address then you've just got a couple long, random sequences with no idea how long the sequences are.
Think about how long it took to decipher ancient Egyptian hieroglyphs. People stared and hypothesized for hundreds of years about what a bird, an eye, and maybe a snake meant, and that's with advanced knowledge of what a bird, an eye, and a snake are. They had plenty of context clues as well like where the hieroglyphs were found. Real understanding didn't come about until a key, the Rosetta stone, was found. Maybe that could be a plot point for your story?
25
4
u/SapientMeat May 13 '20
The analogy to deciphering hieroglyphs is a great one!
If the aliens deciphered English already, that means they've been listening to us. If's possible that they've heard discussions of "the internet", etc. that would give context to the raw data they're receiving.
If they're about as advanced as we are in the 50's, then they have some understanding of data structures and algorithms. While their protocols might be extremely different, there are only so many ways to link data—the building blocks of their technology would have some similarity at least on a conceptual level.
I think it's reasonable to assume that the combination of all these macros would make it possible. They would as u/Northeastpaw said, require a decent amount of context and they already have the means to obtain it.
1
10
u/SpectralModulator May 12 '20
Assuming there's no encryption, they could at the very least extract the plaintext data from our messages, but they wouldn't even have an ASCII table, so they'd have to reverse engineer a lot more than just the transport layer protocols.
0
May 12 '20
[deleted]
6
u/NullBrowbeat May 12 '20
Even Turing had the layout of the weather forecast as an example for a decrypted message for context to crack the Enigma.
1
u/SpectralModulator May 12 '20
It depends on a lot of factors. They might find it trivial, they might not even be able to distinguish the data from random noise on the wire. I'd say if they can reverse engineer the english language and the character encodings then networking protocols shouldn't be any more difficult.
0
May 12 '20
[deleted]
1
u/SpectralModulator May 12 '20
Well there are plenty of wifi signals for them to snoop on. Maybe satellite internet signals too, but that brings the data-link layer issues of actually being able to connect the mothership to a wide-open consumer wifi router, let alone a core router running BGP or something, so maybe they capture some random ISP techie and throw them into the agony booth until they explain everything about human networking technology or something, just an idea.
They could also tap the undersea cables like the NSA does.
0
May 13 '20
[deleted]
1
u/SpectralModulator May 13 '20
If you're presented with a bitstream figuring out what it means isn't always simple even with knowledge of various protocols. If they know english they could just read the RFC from any working computer terminal with a search engine. (assuming they can physically operate a keyboard). And with wikipedia they'd find wireshark eventually and that's a decent place as any to start for someone wanting to snoop network data.
0
May 13 '20
[deleted]
3
u/SpectralModulator May 13 '20
Well that's the tricky thing. Even if they know spoken english, or written english, they'd have to translate each byte to the correct letter, every letter to the correct sound, every sound to the correct actual meaning. Even learning english itself is pretty tricky, we'd end up with a Darmok and Jalad at Tenagra type thing.
4
u/erosPhoenix May 13 '20
(Forgive me if I get some stuff wrong, it's been a while since I've dealt with TCP.)
tl;dr: Aliens would absolutely be able to reverse engineer TCP.
So, TCP is a bidirectional format. These aliens could receive only one side of the transmission, or both. Either way, they'd probably be able to detect some patterns:
- TCP headers have a lot of information that's not useful for understanding the underlying message. However, most of this data will be the same in each packet (like source and destination IP), so the aliens will be able to figure out it's not part of the message and discard it. Similarly, given enough data they'll be able to find packets that are mostly similar but differ only in a few places, which will help them reverse engineer how the checksums are computed.
- The next thing they'll notice is the sequence numbers, which usually increase in a linear fashion with each packet, except when a packet is lost and needs to be transmitted. They'd notice that repeated sequence numbers correspond to re-sent data, and probably also notice how the window size changes over time and correlates with how frequently are broadcast sent. If they have both sides of the conversation, they'll be able to notice how the ACK numbers of one participant correspond to the sequence numbers of the other participant, and the times when the ACK fails to increase correspond to when data gets re-transmitted. With enough data, they'll probably be able to make a good guess on how all these parts (the sequence number, the ACK number, and the window size) work and fit together.
And that's almost all the header that's now been successfully reverse engineered, and this will let them reassemble the transmitted message. Now, whether they understand the message is another beast, but if the message is just ASCII or unicode plaintext, and if they already know the English language, they can do frequency analysis on the message and crack it pretty easily.
3
May 12 '20
As someone said before, It would be more realistic it it was a UDP datagram, intercepting a TCP/IP packet requires a targeted attack the aliens don't have expertise or means for.
That all aside if the datagram contained a large enough piece of plain English text in ASCII, they could run a histogram analysis and work out the encoding. If they understood what bit and byte are that is. If the text was large enough, the headers wouldn't sway the analysis.
3
u/nutrecht May 13 '20 edited May 13 '20
TCP/IP is not a 'format' at all. It's a mechanism of setting up a connection. The data itself is just plain bytes.
It will be completely impossible to have TCP used anywhere where not both ends 'agree'. It is also completely unsuitable for long-distance transmission of data. I don't understand how people claim aliens would be able to 'reverse engineer it'; that's just not HOW TCP works. There won't be anything to 'reverse engineer' for them; they would just keep receiving SYN requests without knowing at all what to do with it. It would be like someone knocking on your door, you answering it, and they just keep staring at you and knocking at that door without telling you anything.
If you haven't seen the movie Contact you definitely should. It shows a much simpler way; radiowaves that contain transmission broadcasts.
1
u/Fuuryuu May 15 '20
What they might be able to see is the plain bytes being sent, and going off that the question is if they can reverse engineer the TCP/IP protocol combination
2
u/NullBrowbeat May 12 '20 edited May 12 '20
How are they even able to receive a stream of data in the TCP/IP format without knowing said format? TCP/IP requires both sides to know the format for the basic syn-ack handshake. It's a protocol designed for a direct two-way connection with error checking. So unless they just randomly eavesdrop on an ongoing conversation, I don't see much chance of directly receiving a TCP/IP data stream.
The question would rather be, how the aliens are even connected to the network so that they can receive said streams of data. Their machines would need to work in a similiar enough manner to ours, that they are capable of even connecting up to an existing cable/other medium and detect the various electromagnetic pulses representing the individual bits. This might be possible though.
Now to how difficult it would be: VERY VERY difficult. In order to fully decode it, they would need context, so they can start deciphering the data. (An example would be something like the Rosetta stone for digital data. - To understand how someone goes about decoding encrypted information [and this information is more or less encrypted in binary] you could look up how the Brits cracked the Enigma code by using a message they knew [the weather forecast] and comparing the encrypted output to the message.)
If they don't have context, they would need TONS among TONS of data, to atleast somewhat make sense of it, but it's questionable if they were able to figure out the meaning of the data, unless they somehow came up with technology, including protocol stacks, that are very similar to ours. (And they would need quite bright minds.)
Edit: I just read it in another comment - I completely forgot about histogram analysis. If they know the English language and thus can also predict the statistical prevelance of letters, they might be able to decode the message, IF they figure out that we group bits in groups of eight and if it were just something simple like a lot of plain text in ASCII that was sent.
2
u/c3534l May 13 '20
I think we need clarity on what you're asking and what you know. Everyone is answering based on the idea that they'd literally have to reimplement the TCP/IP stack, which why would they need to do that? Are you asking if they could decode the data sent out? Are you asking if they could figure out what the internet was? Like, what's the actual thing you want them to understand? A human from the 1950s would probably be able to understand the concept of packets of data, they could figure out numbering the packets, they could extra the data of the message from the header. Are they going to be able to build Firefox or be able to decode a compressed image? Absolutely not.
2
May 13 '20
There ability to work with large quantities would be a major problem. Working their way up from bits to bytes to codes would be bad enough with minimal data. But, considering it's only a sample they would struggle to make sense of TCP/IP beyond working out it's actually a data carrier system. Thinking of decoding it beyond that would requires extensive knowledge of Earth's semiotics. They would need to haul data over years before they could work through something. What you're asking them to do is work through multiple runs on different shredding machines that each leave a puzzle clue on their shredding of the same data. Only an advanced computational logic is going to get through that, and it will still struggle with Earth's languages, meanings, symbols, varieties, ... You're talking about an equivalent operation to the complete works of the US intelligence community and their absolute best efforts at amassing an information army.
2
u/hugthemachines May 13 '20
Do you mean they are in space and they intercepted a stream of data, for example transferred via laser signal or radio or something like that? In that case they may be able to listen to both ways of that communication and understanding it better. If they have reached the earth, perhaps it is likely they can steal a computer, or break in to a house which has a computer, investigating the packets sent by the computer so they learn more.
2
u/codeOrCoffee May 13 '20
Given enough time sure. But it would be incredibly difficult. Its akin to us looking at the radio signals of other star systems in search of life.
Like someone else commented UDP is probably a better approach for realism but you might lose you audience a bit.
To explain the difference between TCP/IP and UDP
The IP part means you need to announce to the network (think of a hall of people) that you exist and you have a name. The TCP part is when you start speaking to an individual person you first say how many sentences you say before they can respond. If you say you speak 2 sentences but they only hear the first one, they will ask for the second one to be repeated. Finally they respond in kind. It may seem slow and it is, the benefit is it ensures the entire message is sent accurately.
UDP on the otherhand is you just screaming in the hall, and listening for anything that makes sense. Its a lot faster, but you can lose message integrity, kind of like you can mishear what they are saying.
The reason UDP is preferred is you can decipher the messages easier as they are self contained. Each one can be read independently of the others. TCP messages need to be grouped together in order and complete to make sense.
2
2
u/umlcat May 13 '20 edited May 13 '20
Could TCP/IP be reverse engineering ... ?
It's a programming question, the answer is possible, but not certain, YES.
Not applied cryptograph technique is 100% sure.
either:
... by aliens ?
... by fairies ?
... by wizards ?
... by elves ?
... by gnomes ?
... by comunists ?
... by racists ?
... by liberals ?
... by democrats ?
... by Hydra ?
... by Anonymous ?
... by ghosts ?
Let's make an example:
public interface Protocol
{
bool TryDecode(Protocol P);
bool TryEncode(Protocol P);
} // class
public class TCPIPProtocol: Protocol
{
public bool TryDecode(Protocol P) ;
public bool TryEncode(Protocol P) ;
} // class
public interface Hacker
{
bool CrackProtocol(Protocol P);
} // interface
public class TCPIPHacker: Hacker
{
bool CrackProtocol(Protocol P);
} // class
public class Alien
{
virtual void FlyShip();
} // class
public class AlienIPHacker: Alien, TCPIPHacker
{
virtual void FlyShip();
bool CrackProtocol(Protocol P);
} // classAny other out-of-the-box PROGRAMMING question ?
2
u/megaSalamenceXX May 13 '20
If humans could in "Independence Day" with just a laptop, then aliens who actually come to earth can do anything.
2
u/hippiesque May 13 '20
I would argue yes. And I just took an IP class so I'm basically a leading expert on TCP/IP.
Realistically, though, I'd say it depends on a lot of stuff. If they can capture packets then absolutely. There are tons of available packet sniffing programs (Wireshark is the one I've used).
If they could only measure the throughput from their location than they could at least get the speedup and slowdown aspects of it.
If all they could do is monitor a single dns server's traffic then yeah but with an enormous amount of data analysis.
So, I guess what I'm saying is, as the leading expert in everything IP for now, it depends on what they are capable of.
Also keep in mind, people do some pretty amazing things with reverse engineering malware, so I think we'd all be pretty surprised at what is possible.
2
u/Blando-Cartesian May 13 '20
Being technologically in the 50’s level doesn’t have to mean that the aliens can’t be far more math savvy than we are. They could have a long history dealing with cryptography or anything else computationally hard that comes handy when decoding unknown communication. Similar to how Nasa benefitted from work of german missile engineers.
2
u/FloydATC May 13 '20
Everyone seems to assume they can read the numbers, forgetting that they would first have to decode whatever layer1 encoding the intercepted signal uses. Are we talking wifi, fiber, ethernet or what? Each have their quirks you would have to completely understand in order to read the layer2 frames correctly. To read those, they would also have to infer that we communicate mostly in octets but in certain places we use bit patterns. Then they would have to guess where the layer3 payload goes. From there, they would have to guess their way all to the application layer and deal with whatever the stream actually contains.
No, I don't think it would be possible in a reasonable timeframe without some kind of reference, simply because of all the odd details at every level. Remember, unlike analog radio signals, hardly ever do network communications "almost" work. You either get it 100% right or you get complete garbage.
1
u/Tubbyball May 12 '20
That’s a very specific question aimed at such a general and unknown thing, but I’d guess very hard
1
u/Loves_Poetry May 12 '20
Probably really difficult. If you don't have any information on the TCP or IP format, then you have no way to distinguish packet headers with metadata and route information from actual packet data. Keep in mind that the content can contain errors and that you need the header information to detect those errors. That's going to make it even harder to decode TCP/IP without knowledge of the protocol
1
u/PeterAnger May 12 '20
My first question is how they learned English. If they learned it on their own without engaging us in anyway, then they are really, really sharp. For context - think about how far we have gotten (or not gotten) in understanding the communications of other animals like dolphins or gorillas... Compared to that feat, being able to decode TCP/IP packets doesn't seem that hard.
If they learned English from interacting with us, then they probably also learned written English, at which point decoding the clear text payloads in TCP/IP packets should be doable. If we onlytaightthem our spoken language then I think decoding TC/IP packet contents would be extremely hard for them to do.
0
75
u/balefrost May 12 '20
I think that fits perfectly within the scope of this subreddit. Plus, I'm sure the people here love something other than "why doesn't my code work" and "what language should I choose for this project?" It's fun to get programming-related questions from other contexts!