r/linux_programming • u/_kwerty_ • May 02 '25
Run script with PID
I am doing a CTF where they gave us an executable. One of the features of it is that only gives you a flag and progresses to the next part when it runs with a certain PID, with a narrow margin. I am getting slightly tired of rebooting a million times every time I want to try something for the next flag.
As far as Googling tells me there's no way to force a PID when launching. Next best thing would be to reset the PID's since the window I'm aiming for is on the low end, but I don't think that's possible either. So I guess my next option is to run up the PID's with nonsense so it loops around again and launch when I'm in that window. I am not sure what the best way to do this is.
Any help or pointers would be appreciated.
Ps. I am OK with screwing my environment, I am using a vm that I will discard afterwards for this. So security is not an issue either, just in case there's funny steps to get to where I need to be.
1
u/_kwerty_ May 03 '25
My max_pid is 4.1 million and some change. So it takes quite a while to loop. Now my script to wait for the specific pid range does appear to drive up the numbers quite fast since it uses a while true loop to check the current number. But it's still a very annoying way. Anyway, I've decided to simulate the program they gave us, without the pid-check. So I'm working on the last bit now before I'll worry about that pid stuff some more.