You cannot customize uname
's output, but you can spoof the installer by making the system run a custom script instead of the "real" /bin/uname
.
First you'll need to check the exact command the installer is running to check your system's information; in this example for the sake of easiness I'll pretend that an executable ~/tmp/check
is running uname -n
and that the output of uname -n
should be ubuntu
in order for ~/tmp/check
to print "Passed!".
~/tmp/check
's source (this of course is not relevant, and is just to showcase what the test executable does):
#include <stdio.h>
#include <string.h>
#define MAX_STRING_LENGTH 32
int main(void) {
FILE* output = popen("/bin/uname -n", "r");
char expected[] = "ubuntu";
char hostname[MAX_STRING_LENGTH];
fgets(hostname, MAX_STRING_LENGTH, output);
pclose(output);
if(hostname[strlen(hostname) - 1] == '\n')
hostname[strlen(hostname) - 1] = '\0';
if(strcmp(expected, hostname) == 0) {
printf("Passed!\n");
return 0;
}
return 1;
}
user@debian:~/tmp$ uname -n
debian
user@debian:~/tmp$ ./check
user@debian:~/tmp$
It's easy to track the exact command run by the executable using strace
:
user@debian:~/tmp$ strace -f ./check 2>&1 > /dev/null | grep execve
execve("./check", ["./check"], [/* 34 vars */]) = 0
[pid 13122] execve("/bin/sh", ["sh", "-c", "/bin/uname -n"], [/* 34 vars */] <unfinished ...>
[pid 13122] <... execve resumed> ) = 0
[pid 13123] execve("/bin/uname", ["/bin/uname", "-n"], [/* 34 vars */]) = 0
So to get around this one should make uname -n
output ubuntu
: the easiest solution would be to just move /bin/uname
and to create a symbolic link /bin/uname
linking to a custom script (which will ignore any argument and just output ubuntu
):
cat ~/tmp/spoofer.sh
:
#!/bin/bash
echo ubuntu
exit 0
user@debian:~/tmp$ sudo mv /bin/uname /bin/uname1
user@debian:~/tmp$ sudo ln -s ~/tmp/spoofer.sh /bin/uname
Let's see if that worked:
user@debian:~/tmp$ uname -n
ubuntu
user@debian:~/tmp$ ./check
Passed!
user@debian:~/tmp$
Bingo! (remember to remove /bin/uname
and to move /bin/uname1
back to /bin/uname
afterwards: sudo rm /bin/uname && sudo mv /bin/uname1 /bin/uname
)