maanantai 29. helmikuuta 2016

(Ab)use of serial ports for fun and profit


Serial ports (as in RS-232) are a wonderful thing. If you are working with microcontrollers RS-232 is superior to USB in just about any way - just about every chip supports it directly, it's extremely simple to use, cheap and you don't have to worry about driver updates bricking your devices (reference explained - while I see their point, destroying users' devices is absolutely disgusting and I personally will never, ever use their products due to this.)

Of course your customers might not like RS-232 that much, but when you are a hacker scratching your own proverbial itch that doesn't matter.

And you can (ab)use the hell out of RS-232 port - just like parallel (printer) ports too, before modern operating systems pretty much killed ability to do so. Unlike parallel port however you can still control almost every signal line of RS-232 with your application directly - and when you realize the implications of this a world of unforeseen applications suddenly opens up.

For example at one point we made a chip card reader that connects to RS-232 port and doesn't need any external power, using just handful of resistors, capacitors and transistors. Simple, efficient and completely against every RS-232 specification that exists!

That chip card reader worked beautifully -- until it met first actual IBM-built PC (yeah, this was a long time ago when IBM actually built PCs and they had actual serial ports built-in.)

RS-232 line specification requires that voltages are either -5 to -15 volts (logical 1) or 5 to 15 volts (logical 0), and everything in between is undefined (I might remember exact voltages wrong but values are close enough for the topic here). So voltages between -5 and 5 are officially invalid, but most RS-232 implementations are happy with logical voltages between -15 to 3 ; and 5 to 15, respectively and approximately. So our reader used zero as logical 1 and whatever port supplied (often 6-12 volts) as logical 0.

This IBM however wasn't having any of it. Its RS-232 port didn't work at all when voltage was at the forbidden zone - between -5 and 5 volts. So we had to upgrade the reader so that it also used negative voltage provided by port so the signals would be more valid. And the troublesome IBM started cooperating too.

This was (I think) close to 20 years ago, so technology-wise this is ancient history, but I suspect that few of these readers might still be in use somewhere. RS-232 however is still the same as back then, so this hack should work as well today as back then. And even with USB-RS232 converters most hacks of this kind still work today.



Ei kommentteja:

Lähetä kommentti