IoT Camera Backdoor

Ok fa/g/gots, so I've been working on reversing the firmware on a Foscam IP camera.

Here's the firmware I'm working on: foscam.us/downloads/MJPEG outdoor waterproof camera-11.35.2.65-20150603.zip

So far I've managed to extract a romfs image of a uClinux installation from the binary file inside of the "System firmware" directory. I've then been able to extract the files from the compiled romfs file onto my computer.

Everything looks pretty simple so far. "/bin/init" is a shell script that mounts some ram devices or something and then runs "/bin/camera" in the background and then starts up an instance of "/bin/sh". What I'm wanting to do is compile and insert a telnet server into the romfs image, recompile that into the Foscam firmware archive and then upload it onto my camera so that I can fuck around with it. The only thing I know about the hardware the camera is running is that its processor is some ARMv7 variant. I don't know how much RAM it has, and I don't know how to go about actually compiling code for it. Any insight or pointers are welcome.

Also, general IoT device hacking thread.

Other urls found in this thread:

onlinedisassembler.com/odaweb/mSAfgEju
irishjesus.wordpress.com/2010/03/30/hacking-the-foscam-fi8908w/
justreadthecode.wordpress.com/2013/10/04/ipcamera-fun-part-2/
twitter.com/AnonBabble

Alright, I poked around with the "/bin/camera" program and figured out that it is in a bFLT binary format, and all of contents of the program are gzip compressed (except for the bFLT header, of course) and I'm currently looking at the assembly and strings inside of the raw binary.

Here's an online disassembly of the program: onlinedisassembler.com/odaweb/mSAfgEju

If it tells you that it can't figure out where the entry point is, just hit "Yes" and it'll assume it's at the beginning of the file.

What is this, a good thread on Sup Forums? Get the fuck outta here with this actual content.

where did you start on reverse engineering, would be cool if you were able to inject a ssh/telnet backdoor on these cameras.

>where did you start on reverse engineering
In general or on this particular project?

I've got nothing that I can contribute to your project OP, I just wanted to say that it's very interesting. Please keep us updated, and good luck!

That's pretty rad.

In general, please. I'm tired of working on pointless shit.

>would be cool if you were able to inject a ssh/telnet backdoor on these cameras.
Assuming I can get over the compilation hurdle, this should be pretty trivial. There's a page on the camera's built-in webserver that allows you to upload firmware binaries directly from your computer. Not sure if the binaries are supposed to be signed or not, but assuming how shitty and monolithic the /bin/camera strings/code is, I doubt that Foscam gives enough of a shit to verify that.

It would probably be easier to exploit some vulnerability you might find when reversing some of the binaries on that camera. Creating your own firmware update can be easy if there's only stuff like simple checksumming involved, however you are probably most likely going to break it by doing it that way. If you mess something up while rebuilding the filesystem and the camera is actually going to update with your file, you'd be screwed.

Not sure how I can get around that desu. I can't find any docs online describing the hardware in detail so it's not like I can run a VM simulating the camera. If there's going to be any exploitable code, it's most likely going to be in /bin/camera or /bin/wetctl since those seem to be unique to the hardware. If only I wasn't shit at finding exploits though...

I don't have anything to contribute but this is a great thread, thanks OP

i have these cameras pls delet this thread

A statically compiled version of qemu is always helpful to debug. Most embedded devices have shit security so you should be able to find something. The firmware update function for example. Take a look at where this is being handled and what it does. It might invoke system() with some user controllable parameter.

Honestly it's just a matter of finding a device or piece of software that you REALLY wanna break/crack/figure out how it works and just researching all of the methods to do so. I started out around 8 years ago with "hacking" GBA ROMs. My best piece of advice though, is if you want to know how to crack into some hardware or software, you'll learn more by trying to replicate its behavior than you will by beating your head against it over and over trying to brute-force your way in. That's just my 2 cents though, ymmv.

There's a shitton of semi-prepared shell command strings inside of /bin/camera, some of them which might also format with user input, so I think that's where I'll start. Thx friendo

No problem friend-a-who

Maybe not the same model but this guy has 4 blog posts about it.
irishjesus.wordpress.com/2010/03/30/hacking-the-foscam-fi8908w/

That's actually the blog where I found out to trim the first 20 bytes off the firmware binary to get a slightly malformed but usable zip file. I only read his initial blog post though, I didn't realize that he posted more. Thanks

In case anyone is still following along, I found another blog post that explains in detail how to run individual ARM binaries from this particular camera's firmware in qemu and also how to calculate the checksum for custom firmware.

justreadthecode.wordpress.com/2013/10/04/ipcamera-fun-part-2/

If you upload /bin/camera I'll open it up in IDA and give it a look.

What do you use to decompile?

Could you recommend any reading material on the subject?

this

>quality thread
>on Sup Forums
I'm truly shocked.

Inb4 someone posts an iphone and says "you mad Sup Forums?"

Can someone suggest another website which has this kind of general hacking?

I am asking of this because I know this level of discussion on this board can surely not last long

Your local hackerspace's wiki.