msgbartop
Adam Palmer MBCS CITP, Linux, PHP Programmer, MySQL Developer, Embedded Hardware, Security Consultant
Did my blog help you? Please link to me!
  dns test
 
RSS Feed
msgbarbottom

02 Nov 09 Easy Reverse Engineering

Compiling a program doesn’t protect it or necessarily hide the source. Take the following example C program. It serves no real life purpose and should never print anything to the console:

#include <stdio.h>

int main(void)
{
        const char *password = "secretpassword";
        const char *otherpassword = "othersecretpassword";

        if(!strcmp(password, otherpassword))
        {
                printf("This will never get evaluated");
        }
        return 0;
}

To assemble the code using gcc -S test.c leaves test.s. The important point being that all strings remain intact:
(more…)

Tags: , , , , ,

03 Oct 09 Linux C setuid setgid tutorial

Here’s a very brief example of how to use setuid() and setgid() functions in your C program.

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

int main(void)
{

int current_uid = getuid();
printf(”My UID is: %d. My GID is: %d\n”, current_uid, getgid());
system(”/usr/bin/id”);

if (setuid(0))
{

perror(”setuid”);
return 1;

}

//I am now root!
printf(”My UID is: %d. My GID is: %d\n”, getuid(), getgid());
system(”/usr/bin/id”);

//Time to drop back to regular user priviledges
setuid(current_uid);
printf(”My UID is: %d. My GID is: %d\n”, getuid(), getgid());
system(”/usr/bin/id”);

return 0;

}

The program above should be pretty self explainatory, now:

adam@staging:~$ gcc -O2 -ggdb -o setuid setuid.c
adam@staging:~$ ls -al setuid
-rwxr-xr-x 1 adam adam 9792 2009-10-03 18:09 setuid
adam@staging:~$

(more…)

Tags: , , , , ,

04 Sep 09 Multithreaded Multi-Connection TCP Proxy Tunnel Update

Further to post http://www.adamsinfo.com/multithreaded-tcp-proxy-tunnel-code/

I have received a report from a user experiencing the following error:
# gcc -Wall -g -O2   -o tcp_tun tcp_tun.c  -lpthread
tcp_tun.c:44:37: error: getaddrinfo/getaddrinfo.h: No such file or directory
tcp_tun.c:45:37: error: getaddrinfo/getaddrinfo.c: No such file or directory

I think that this is a common error involving distros without getaddrinfo available. I have packaged up everything up with getaddrinfo and a configure/Makefile also. Please let me know your feedback.

tcp_tun-0.3-beta

Tags: , , , , ,

18 Aug 09 Multithreaded TCP Proxy Tunnel Code

Further to my earlier article, I went ahead and developed this application. Here’s a beta!

File: tcp_tun.c
Version: 0.3-beta
Title: TCP reassembling client-server application
Date: 17 Aug 09
Author: Adam Palmer <adam [AT] adamsinfo [DOT] com>
URL: http://www.adamsinfo.com/
(more…)

Tags: , , , , , , , ,

05 Aug 09 Using the Phidget Interface Kit under Linux

Further to a comment I received http://www.adamsinfo.com/the-robot-phidgets-usb-interface-board-kit-works/comment-page-1/#comment-490 I thought that it might be a good idea to write a quick high level overview of getting the USB Phidget Interface Kit working under Linux. In my case I am of course using 32bit Debian, however these instructions should mostly be portable to any other Linux based OS

(more…)

Tags: , , , , ,

26 Nov 08 Using distcc for distributed compiling on an alix 3c2

Since I’ve been working on the alix board for the robot it’s become increasingly useful to just compile software on the board itself rather than on a host machine – with an AMD Geode 500MHz processor, it’s certainly capable.

I generally work on a USB hard drive attached to one of the spare ports whilst I’m testing stuff live, and then I back up the hard drive every so often.

I made some modifications to the cp2102.c kernel module and I wanted to recompile the kernel on the board directly as I had some other modules I needed, such as for the wifi card. 2.6.18 compiled eventually over about 7 hours but after wanting to make further kernel changes, I decided that I didn’t have another 7 hours to wait. I decided to use distcc to compile ‘locally’ but use the processing power of any number of other servers.
(more…)

Tags: , , , , , , , , , , , , , , , , , , , , , , ,