Introduction: How to Build Your Own USB Keylogger

Picture of How to Build Your Own USB Keylogger

Cause I've searched a lot for a project like this, and I haven't find anything around the Web, I would share my experience of my personal USB Keylogger.
It's not really a pure "USB" Keylogger (cause USB HID protocol is much more difficult than PS/2 protocol), but it adapt an USB Keyboard to PS/2 port, while (of course) recording the keys pressed.
In this way, even if it's discovered by anybody, it should be confused with a normal PS/2 Adapter.
That's the final result:

It need just a few component (SOIC PIC and EEPROM can be freely ordered as a sample from ):
-PIC 12F1822  (SOIC Version)
-EEPROM 24XX1025 (Any 1Mb version will be ok)  (SOIC Version)
-2 * 4k7 Resistor 1/8 W (Or any resistor of the same value as small as you can solder in the adaptor)
-Pickit 2 / 3 (For programming the pic and reading the eeprom)
-An USB to PS/2 Adapter that can be opened.

And, very important:
-A GOOD solder and VERY GOOD soldering abilities.

Let's Start.

EDIT (in reply to comments):
Some weeks ago, a friend of mine asked me to help him, cause his computer seamed blocked, indeed, he couldn't either type his password to login with his account..
I know that he is almost a novice and couldn't just change the keyboard instead of asking me help, anyway, i changed his keyboard, but I wanted to know why it wasn't working, I tried it on another computer without any result, except that the keyboard's leds blinked, so, I wanted to go deeper; I take a Logic Analyzer and i have analyzed the PS/2 protocol, I have discovered that the keyboard was switching off whenever the PC sends 0xFF (Reset) command.. I then solved it simply replacing a capacitor that has blown up.

This is WHY I build it (for any similar case), I'm NOT responsible of ANY aim you use this Keylogger.
Illegal is the WAY you use a Keylogger, not the Keylogger by itself.
I didn't want to make anything "immoral" or "illegal"


Step 1: Circuit

Picture of Circuit

This is the complete circuit of the Keylogger, it can seems complex, but in real, it isn't.. we'll see why..
It is divided into two "zones":
One is the Adapter, which connect GND and VCC pin of PS/2 connector with their respective pins on the USB Connector and CLK and DAT pin to, respectively, D+ and D- pins.
The other zone is composed by the PIC and the EEPROM (and the I2C required pull-up resistors). The PIC take care of detecting incoming Data from PS/2, decode, and then writing it to the EEPROM.

Step 2: Open Up

Picture of Open Up

Open up your USB to PS/2 Adapter, it should look like this.
It simply connect pins from USB female to the PS/2 male connector.
All the wires are glued together with some kind of silicone or something similar, so you have to carefully remove that with a diagonal pliers or anything similar.
You should remain with the separated Female USB and the Male PS/2 connector and the plastic holder.

Step 3: Solder First "Zone"

Picture of Solder First "Zone"

This shouldn't be too hard, just join:
D+    -> CLK
D-     -> DAT

See here  for USB Pinout.
See here  for PS/2 Pinout

It will look like this:

Step 4: Solder PIC and Program It

Picture of Solder PIC and Program It

You need to temporarily solder your PIC onto a small piece of surface-mount board or by solder a wire to each pin, one by one.
No matter which way you have chosen, you need to be able to connect your PIC to Pickit 2 or any other PIC programmers that support PIC 12F1822.
I've written the code using PCW from CCS, so, if you want to modify the code, feel free to modify or distribute it as you wish, just mention this guide if you want to redistribute it :)
I've attached also the .hex if you want to simply copy what I've done :)
I don't i enter into details of programming, because I expect that you already know how to do that.

Step 5: Solder PIC and EEPROM

Picture of Solder PIC and EEPROM

Here the bad step.
Here you need to take all you soldering abilities to correctly solder the PIC with the EEPROM, and the two Pull-Up resistors..
It's REALLY not so easy, so, if you aren't an expert of soldering, I advice you to leave this project, or to ask a friend of you to make that for you.. 
After some days of working, this is my result:

Step 6: Read EEPROM After Logged

Picture of Read EEPROM After Logged

After the soldering process and re-assemble you Keylogger, you should connect to the keyboard that you want to log and wait for the information, "legal" data, or anything you want to get from this Keylogger..
Then, unplug the Keylogger and re-plug the keyboard ;)
Now, you have to read from the eeprom, so, If you have soldered also the SDA and SCL pin to the two N/C pin of PS/2 (like it was on the circuit) you can now build a simple converter from PS/2 to ICSP connector of your EEPROM-reader (In my case, Pickit 2).
See the documentation of your programmer to see exactly how to build it.
Mine, look like this.
After read the eeprom memory, you should save it to a file for better usage. You can do this with a simple Hex Viewer.
Remember that the data collected from PIC are pure "keyboard scancodes", so you need to convert to a readable version.
You can do this by hand, basing your conversion process to this link .
Another way is to use my homemade program, made for make this process easier.
I've attached it, but BE AWARE, IT'S A ALPHA VERSION, it's FULL of bug and REALLY not optimized.
By the way, it make his work quite well..
It's an Italian Version 'cause I'm Italian ;)

Step 7: Conclusion

Picture of Conclusion
Here we are. 
I don't know how many will have the bad idea of make this Keylogger, but, if you really want an homemade (and almost free) solution to log a keyboard, this is what you're searching!
Feel free to comment and ask question about this project :)
Here's a summary video of this project:


monoverde (author)2011-05-06

One great use for a hardware Key logger is for additional backup during a big writing project. Can save a lot of time after a big crash.

wthit56 (author)2011-05-05

Wow. Controversy! ;P

I'm not a paranoid crazy who wants to ban kitchen knives and prescription drugs. I'm even fine with jump ropes and aspirin.

I realize there are legitimate uses for such technology, but some (employee/child monitoring, etc.) do not require any covert operation, and therefore can simply be done using software... and others (police use, etc.) would have their official ways of doing such things, and wouldn't be looking around the internet for a solution to their problem.

I'm not entirely sure why people are giving reasons for legitimacy including things like "making sure my children's internet browsing is safe", or "emergency back up of your work in case of hardware failure". These things can be done very easily with numerous software suites out there. A keylogger is to log a computer's activity, and not much else. Software on the other hand, can backup files, stop a user browsing unwanted sites, and all number of things - none of which require any secrecy or underhandedness in any way.

And the "it's only illegal if you don't ask the victim's permission" makes no sense. The whole point of making this kind of hardware is to log secretly, with the victim being any the wiser.

I think we all know this kind of tech is used for illegal acts far more often than legal ones. Whilst the people commenting on this item may not be interested in it for hacking/cracking purposes, there's a lot of people out there who would use it that way.

Which brings me onto "freedom of speech". People have commented that it's like going onto a gun forum and telling the people on there to not post stuff on guns, which is an interesting point. However, if someone posted a "how-to" on building your own bomb, how would you react? Whilst bombs may be used to stop terrorism, or save lives in some way, there are lots of people out there wanting to just make bombs. And kill people. Innocent people. If someone has a legitimate use for a bomb, then they would presumably be in the army, etc., and so have authorization to use such things. People looking on the internet for ways to make bombs aren't going to be making them for the army. They're going to be making it for themselves - to use it for their ends, which is usually not a good thing.

Now a keylogger isn't a bomb. I am aware of this. But I hope you can see the parellels. People looking online for how to make a keylogger aren't usually going to be the kind-hearted concerned about a friend type. They're the hackers and crackers who want to steal your information, passwords, etc., or to hack into your system.

Let's go back to the guns analogy for a moment. Gun sales and distribution is heavily regulated and monitored. Anyone who wants to carry a gun must be certified and each gun they purchase must be registered to the owner. If someone put up a "how to make your own 9mm hand gun" on instructables, then this system would be completely disrupted. Anyone could make their own gun, and therefore, anyone, no matter how trustworthy or mature, would be able to fire a weapon at whatever the like, whenever they like. "But it's freedom of speech. It's the usage of it that's illegal." I'm fairly sure the police would disagree.

For these reasons, it's not a good idea to post things of this nature on the internet. If you have a case for legitimately monitoring a PC's activity, then look into the wide array of other, less dubious options, or if it's serious, talk to the police or someone of authority abot it. I'm sure you can find another option.

Jamby (author)2011-05-05

Some weeks ago, a friend of mine asked me to help him, cause his computer seamed blocked, indeed, he couldn't either type his password to login with his account..
I know that he is almost a novice and couldn't just change the keyboard instead of asking me help, anyway, i changed his keyboard, but I wanted to know why it wasn't working, I tried it on another computer without any result, except that the keyboard's leds blinked, so, I wanted to go deeper; I take a Logic Analyzer and i have analyzed the PS/2 protocol, I have discovered that the keyboard was switching off whenever the PC sends 0xFF (Reset) command.. I then solved it simply replacing a capacitor that has blown up.

This is WHY I build it (for any similar case), I'm NOT responsible of ANY aim you use this Keylogger.
Illegal is the WAY you use a Keylogger, not the Keylogger by itself.
I didn't want to make anything "immoral" or "illegal"


AndreaC315 (author)2017-11-10

Hi! If I build this and then get a PS/2 to USB adapter, so that i can connect a USB keyboard to the keylogger, keylogger to adapter, adapter to USB port, would it still work?

p96xlyuri (author)2017-02-19

can this be made with a usb connector?

rajasakthikumar (author)2016-10-12

bro how to make usb to usb hardware keylogger . because i want to spy my sis computer which uses usb keyboard

Aalexz (author)2016-09-21

THANKS! I made it! But seriously, did you need to get the chips as a free sample? The PIC is £0.81 on RS (free delivery) :D

AmanL3 (author)2016-04-27

Can I use a PIC12F508?

Jamby (author)AmanL32016-04-30

I don't have big knowledge about PIC12F508, but at first sight it lacks an I2C interface and the LtoH/HtoL interrupts that are used in this project. You could write your own procedure to communicate with the EEPROM with software implementation of I2C or other sort of communication but you should be very careful since it will require lot of precision due to the internal oscillator (I don't even think that the internal 4Mhz oscillator can handle I2C properly); the same is for LtoH/HtoL interrupts, you could check the values in a periodic timer but you will probably lose some bits if not calibrated correctly with the speed of the PS2 protocol.
So the final answer is "maybe, but it will require for sure some work to adapt this solution".

private_1 (author)2016-04-20

I like the idea but how would the chip fit into the ps/2 adaptor.

And how would you read the keys pressed after the key logger is dine

xp4xbox (author)2016-01-31

Cool. I still prefer software keyloggers though.

MichelleD70 (author)2016-01-07


MichelleD70 (author)2016-01-07

Software keylogger like Micro keylogger is easy to use.

markg52 (author)2015-09-20

very good information about keylogger.

for more cool tips visit

iagolps (author)2015-08-11

hi, I'm trying to use proteus, but it seems that my library isn't complete, the eeprom and the pic is different or doesn't have somebody know what can i do, like download the library folder or someone could make available there own folder...

Ploopy (author)2015-07-21


I don't have a pic or a pic programmer, so I might try this on attiny85.

hitech444 (author)2015-06-12

It seems strange to me that noone noticed - 4 years now - the other 2 little mistakes on the circuit (along with ematiss' comment on the 2 Vcc chip pins that should be connected to connector Vcc line):

The pin numbers from pin 5 to pin 8 are shown wrong... For U1: SDA is pin 5, SCL is pin 6, WP is pin 7 and Vcc is pin 8.

Same for U2: RA2 is pin 5, RA1 is pin 6, RA0 is pin 7 and GND is pin 8.

My congrats to Jamby: Simple and elegant

pablo7890 (author)2014-11-28

Hi! I'm wondering if it is possible to replace PIC 12F1822 with avr unit like an ATTiny85 or something similar. Thanks!

deadpool1001 (author)pablo78902015-03-30

The ATtiny85 is good, but is not very good at storing information as it has limited space. Other ATtinys have more space and can even store to miniSD cards.

Jamby (author)pablo78902014-11-28

Oh, yes! I think it should work without problem.
Unfortunately, I've very few experiences with AVR, so I can't indicate you the best AVR (while ATTiny85 looks indeed really nice). The only particular feature I've used for this project is the interrupt on low-to-high transitions, in order to easily sync with the PS2 protocol; btw, it could be done even with correctly timed timers with little effort.

pablo7890 (author)Jamby2014-11-28

Thank you for replying and those tips! I'll try it, maybe I'll find the way to make it working :)

obrubov (author)2013-10-29

I want to present their implementation of USB keylogger. In contrast to the presented here is a pure USB keylogger that analyzes the protocol USB. Unfortunately, this is only the layout, not the final product. And unfortunately article in Russian.

ematiss (author)2013-05-09

In the schematic vcc is connected between the chips, but not to vcc itself. Is this connection implied?

Jamby (author)ematiss2013-05-10

Yeah! You're right! Congrats to have discovered that huge mistake. UC VCCs must be connected to USB VCC.

JamesHurst (author)2013-03-06

Thanks for sharing your project. The schematic looks nice and clear, but.. what code did you program your PIC microcontroller with? I would think this is incomplete without the code that drives the microcontroller, no?

Jamby (author)JamesHurst2013-03-07

Source code can be found in step 4.

mtnchrismtn (author)2011-05-16

There are many reasons that this keylogger would need to be disguised....

Example A: A parent wanting to know what their children are doing online and don't want their child to discover said keylogger....

Example B: That pesky room mate always on your computer? Yeah well now you know what they are doing on your stuff...

Example C: A cheating spouse????

I can do this all day, and with an equal number of illegal reasons on might need such a keylogger.....

The point is, Not everything is or should be illegal.. There are many instances where ownership of an item is NOT illegal...

Example A: It is COMPLETELY LEGAL, to make and own your own gun, (called garage guns), yep legal.....

Example B: Did you know you can buy a grenade launcher?, yep legal..

There are numerous items that CAN do serious damage to anyone with the right person using them... And are completely legal to get or make yourself....

That being said, this small keylogger, yeah it could be used to steal your personal information in the right hands, and it could also be used to protect yourself from that pesky room mate using your computer to find kiddy porn....

And on that Note, Jamby I give you props for this awesome idea...

And all the critical people bashing on this cause it conceals itself, get with the times, this is the last thing I am worried about in my life.... Try worrying more about your neighbor and his grenade launcher.........

also on the grenade launcher (common household item right?.... well in my house at least) tactical gear commando, check the site out i found a mounted fifty cal machine gun for sale, lol sooo on my christmas list.

Guess I made it quite obvious, the wonderful things I take interest in, haha... Thanks man, I will check it out...

mtnchrismtn (author)mtnchrismtn2011-05-16

And also I would like to add, you can "BUY" keyloggers that conceal themselves.... Yep totally legal......

kityuen (author)2011-12-17

Thank you for sharing the knowledge. Honestly I sell USB products for around 3 years (hkcolordigital) but it is my first time to see this kind of product here. I would recommend our manager to consider adding the keylogger into our store.

actually as a remark to tgiles comment there are perfectly legal reasons to use these, my friends dad used it on his home computer to prevent tampering on his computer. he had it so that if anyone tried to log into his computer it would record anything that was typed so he knew what they where after. he did "important code writing stuff" so he was pretty paranoid.

johnpoole (author)2011-05-30

wow.. i would have never guessed that this would have gotten those responses. not that i agree or disagree.. back to the logger, i need one for work and that's a great build. thanks..

just a comment on the gun thing, i can buy a gun via a classified without showing id. i can buy from a gun store with just a driver license, no waiting period. i would need a course to carry concealed but i have a gun rack in the truck, not concealed, but loaded. an armed community is not only safe, but tends to be polite. it seems that if the bad guys know who's armed, they tend to pick on someone else..

cparida (author)2011-05-22

too complicated and not completely free

silveruno (author)2011-05-05

well, that would be illegal in my country to use that kind of hardware.

asoo1 (author)silveruno2011-05-21

is it illegal if i use it in school computer? :D

Krytenthesmug (author)silveruno2011-05-06

Which country is that? They are legal in the UK and US as a means of ensuring no inappropriate use of computers at work. However, these are normally replaced these days by keylogging at the server.

mudasir (author)2011-05-15

great job man...

asteidl (author)2011-05-10

Good links to USB and PS/2 information. Easy to see you've done your research!

Arcagelinos (author)2011-05-10

Everything can be misused
A kitchen knife can cut the bread but can also stab a man with it
Used responsibly and it shouldn't be illegal.

fishfryer (author)2011-05-05

Personally, I think that it is perfectly fine to have something like this. and even though it's mainly all been said already, and I can't stand to perpetuate arguements, I have a few new points.

owning something isn't a crime. a criminal act with the item is.
But accusing someone of the capability to do something is ridiculous. It would be like Orwell's "Thought Police"

More so, it IS like some non-fictitious historical groups that were unjust.
for example, the Gestapo*, the Red guards, and the Soviet Era internal KGB.

these were not the nicest people to be around. Okay?

*Nazi secret police, often mistaken as gazpacho, a tomato soup.

paqrat (author)fishfryer2011-05-08

Actually there are many instances where ownership of an object is a crime. Certain drugs being one of them. Also the possession of certain weaponry or when a weapon is possessed by a convicted felon. Possession of certain types of explosives is also illegal. Possession of a stolen object is generally illegal.

I agree that accusing someone of the capability to do something does sound rather ridiculous but capability of commiting a crime will be a key portion of evidence if someone is being investigated or tried for the comission of a crime.

The problem I see in this instructable is that it is designed to pass for something other than what it is. The true nature of the device is disguised, intentionally disguised. If it was for one's own use there would be no need to disguise its true function. For one's use the device enclosed in a black box would serve the same purposes of backup or testing the system.

Use of this device on computers other than on one's own may be legal or not depending on the circumstance but I think in most cases use of this device without the knowledge of the computer user on whose computer it is installed is dishonest.

fishfryer (author)paqrat2011-05-09

I actually agree with you on that. I must admit I didn't quite make my own opinion clear on this one, and you generally summed up the rest of it. thanks.

magiko (author)2011-05-09


Your points are well stated and well received.

My point of view, however, is something different.

To block discussion of nefarious tools we would do a disservice to two important groups of people.

1) There are plenty of people who wish to learn and hack and use this knowledge for themselves. Turns out, these people come up with plenty of legit uses for nefarious devices all the time.

2) The people who need to protect themselves from people who would make such a device. Where would you send these 'white hats' - to the hacker underground with the black hats?

Another way to state that - If we close our ears to this topic, it does not make the topic go away, it simply makes us dumb about this topic.

You can say freedom of speech, blah, etc (which is all very true and very important) - but there's something more important, which is the freedom of information (not price). Stop people from knowing how to build a bomb, a keyboard logger, or anything else, and suddenly we have a black list of "things [someone] says you can't know how to do" -- thought crimes are currently not crimes and I'd prefer to keep it that way. Knowledge is always power and restricting knowledge is always evil.

duct tape (author)2011-05-08

Would this configuration of the microcontroller/eeprom still work if you used a usb to usb instead of ps/2 to usb? Obviously you would need to figure out a new way to dump the memory but would that still work to capture the data?

Jamby (author)duct tape2011-05-08

Unfortunately No. USB HID protocol is different (Maybe I'll analyze in another instructable). Just think for example that PS/2 protocol is Open-Collector-Protocol (so it needs pull-up resistors) while USB does not.

techwiz (author)2011-05-08

What program did you use to make that very nice circuit diagram?

Jamby (author)techwiz2011-05-08

I've used ISIS, from Proteus (LabCenter Electronics)

fitzyt (author)2011-05-05

Somebody said the Freedom of Information Act protects keylogging other people's computers? That's like saying the NRA protects international terrorism.
The FOI Act is for the people to obtain requested documents about the proceedings of our Federal Government. The Privacy Act of 1974 expressly confines the FOI to government records (wikileaks kinda stuff) and NOT personal information about individuals. Employers have the right to track web activity and email. Employers do not have the rights to keylog employee passwords, by the way. That's the employee's property, and is the "electronic signature" of the employee and can be used for electonic forgery and fraud.

adrenalynn (author)fitzyt2011-05-05

That would be incorrect. My employee manual clearly states that you agree to monitoring of any and all activities on company property. There is no password on the property that belongs to you if you enter it into company property. If you don't like it, you are welcome to find other employment. We've had it tested several times and it holds up just fine.

The computers are company property. The connectivity is company property. The phone is company property. If you're doing something personal on company property, then you're either stealing resources from me or it belongs to me. Your choice.

[Where "You" is the "Royal You", not "You" specifically...]

About This Instructable




More by Jamby:How to build your own USB Keylogger
Add instructable to: