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: C, gcc, Linux, ls, reverse engineering, strings
Here’s a very brief example of how to use setuid() and setgid() functions in your C program.
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:
Tags: C, gcc, Linux, setgid, setuid, System
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.
Tags: C, gcc, Linux, tcp, tcp proxy, tcp tunnel
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: C, code, debian, gcc, Linux, multithread, tcp, tcp proxy, tcp tunnel
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
Tags: debian, gcc, Linux, phidget, phidget interface kit, usb
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: /etc/hosts, 2.6.18, 3c2, alix, apt-get, build kernel, cc, CC=distcc, compiled, cp2102, distcc, distccd, DISTCC_HOSTS, distributed compiler, g++, gcc, Intel Xeon, kernl module, ld, libc6, libc6-dev, Linux, make, the robot