Detecting cron tasks run by another user

Clash Royale CLAN TAG#URR8PPP
I am currently working through the Nebula challenges on exploit-exercises.com, and one of the challenges relies on a script being run by cron.
This is run by another user (flag03) and the user I am logged in as (level03) doesn't have privileges to run crontab -u flag03 to view the job.
The hint clearly indicates the script is run by cron. Additionally, it is the only script in the /home/flag03 directory, so we would likely investigate further.
However, if this was the real world, I wouldn't know that this script was being run by cron.
Therefore the question is, how would I detect that the task was being run from the perspective of an unprivileged user?
I have tried the following:
while true; do ps au | grep <scriptname> | grep -v grep; done;
This allows me to see processes that run for a significant length of time, but not ones that exit almost immediately. It also presumes I know the name of the script.
The specific environment is Ubuntu. I can't use apt-get, but I have access to gcc.
Any ideas?
cron privileges
add a comment |
I am currently working through the Nebula challenges on exploit-exercises.com, and one of the challenges relies on a script being run by cron.
This is run by another user (flag03) and the user I am logged in as (level03) doesn't have privileges to run crontab -u flag03 to view the job.
The hint clearly indicates the script is run by cron. Additionally, it is the only script in the /home/flag03 directory, so we would likely investigate further.
However, if this was the real world, I wouldn't know that this script was being run by cron.
Therefore the question is, how would I detect that the task was being run from the perspective of an unprivileged user?
I have tried the following:
while true; do ps au | grep <scriptname> | grep -v grep; done;
This allows me to see processes that run for a significant length of time, but not ones that exit almost immediately. It also presumes I know the name of the script.
The specific environment is Ubuntu. I can't use apt-get, but I have access to gcc.
Any ideas?
cron privileges
1
Can you look at anything under/var/log/? Look for log messages about cron tasks.
– slm♦
Jun 6 '14 at 18:09
No, unfortunately no permissions or not relevant (grep -ri cron / or find / -name cron)
– Cybergibbons
Jun 6 '14 at 19:15
add a comment |
I am currently working through the Nebula challenges on exploit-exercises.com, and one of the challenges relies on a script being run by cron.
This is run by another user (flag03) and the user I am logged in as (level03) doesn't have privileges to run crontab -u flag03 to view the job.
The hint clearly indicates the script is run by cron. Additionally, it is the only script in the /home/flag03 directory, so we would likely investigate further.
However, if this was the real world, I wouldn't know that this script was being run by cron.
Therefore the question is, how would I detect that the task was being run from the perspective of an unprivileged user?
I have tried the following:
while true; do ps au | grep <scriptname> | grep -v grep; done;
This allows me to see processes that run for a significant length of time, but not ones that exit almost immediately. It also presumes I know the name of the script.
The specific environment is Ubuntu. I can't use apt-get, but I have access to gcc.
Any ideas?
cron privileges
I am currently working through the Nebula challenges on exploit-exercises.com, and one of the challenges relies on a script being run by cron.
This is run by another user (flag03) and the user I am logged in as (level03) doesn't have privileges to run crontab -u flag03 to view the job.
The hint clearly indicates the script is run by cron. Additionally, it is the only script in the /home/flag03 directory, so we would likely investigate further.
However, if this was the real world, I wouldn't know that this script was being run by cron.
Therefore the question is, how would I detect that the task was being run from the perspective of an unprivileged user?
I have tried the following:
while true; do ps au | grep <scriptname> | grep -v grep; done;
This allows me to see processes that run for a significant length of time, but not ones that exit almost immediately. It also presumes I know the name of the script.
The specific environment is Ubuntu. I can't use apt-get, but I have access to gcc.
Any ideas?
cron privileges
cron privileges
edited May 3 '18 at 18:50
José Castillo Lema
25119
25119
asked Jun 6 '14 at 7:05
CybergibbonsCybergibbons
1362
1362
1
Can you look at anything under/var/log/? Look for log messages about cron tasks.
– slm♦
Jun 6 '14 at 18:09
No, unfortunately no permissions or not relevant (grep -ri cron / or find / -name cron)
– Cybergibbons
Jun 6 '14 at 19:15
add a comment |
1
Can you look at anything under/var/log/? Look for log messages about cron tasks.
– slm♦
Jun 6 '14 at 18:09
No, unfortunately no permissions or not relevant (grep -ri cron / or find / -name cron)
– Cybergibbons
Jun 6 '14 at 19:15
1
1
Can you look at anything under
/var/log/? Look for log messages about cron tasks.– slm♦
Jun 6 '14 at 18:09
Can you look at anything under
/var/log/? Look for log messages about cron tasks.– slm♦
Jun 6 '14 at 18:09
No, unfortunately no permissions or not relevant (grep -ri cron / or find / -name cron)
– Cybergibbons
Jun 6 '14 at 19:15
No, unfortunately no permissions or not relevant (grep -ri cron / or find / -name cron)
– Cybergibbons
Jun 6 '14 at 19:15
add a comment |
6 Answers
6
active
oldest
votes
Maybe using inotifywait in the /proc/[0-9]+ directories would let you have a better glimpse of short run processes.
add a comment |
Looking at the challenge this method of attack would assume that you can run a script and watch what runs on the box, so I would write a script that simply does a dump of ps -eaf every couple of seconds, this would catch a cron, eventually, since crons run once every minute.
This vector of attack would require you to watch for this script running, note the location of the script, and dig in deeper.
Isn't that pretty much the one-liner I posted in the question?
– Cybergibbons
Jun 9 '14 at 8:13
@Cybergibbons - more or less. I'd modify the script slightly and there are other ways to watch for processes running, so if this wasn't successful in finding any cronjobs, I might dig in deeper with those.
– slm♦
Jun 9 '14 at 11:58
add a comment |
In this specific case, the file is located on /var/spool/cron/crontabs/flag03, and you can read it with the nebula account.
But level03 doesn't have enough privileges to access it.
add a comment |
Which version of Ubuntu? If it's using systemd, you could rely on the cron cgroup created by systemd I guess, as all processes started by cron will be a direct child.
One of the option to get this information is to use the ps command with something like:
ps -eo user,pid,cmd,unit | grep cron.service | grep flag03
Why does this not suffer from the same issue as the suggestion in the question i.e. short lived processes will be missed.
– Cybergibbons
Dec 20 '16 at 14:39
Indeed, but you could mix that with the idea from @piroux and add a inotify watch on the files in/sys/fs/cgroup/systemd/system.slice/cron.service/
– Bigon
Dec 20 '16 at 15:27
add a comment |
You can't. The closest you can get is:
inotifywait -m /home/flag03/script
That won't show execution but it will show when script is opened or accessed.
add a comment |
while true; do ps aux | egrep -v "grep|tail|aux" | tail -n 1; sleep 1; done
3
Give more info, it is a Q&A site and not a snippet sharing one.
– peterh
Dec 11 '16 at 7:52
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f134800%2fdetecting-cron-tasks-run-by-another-user%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
Maybe using inotifywait in the /proc/[0-9]+ directories would let you have a better glimpse of short run processes.
add a comment |
Maybe using inotifywait in the /proc/[0-9]+ directories would let you have a better glimpse of short run processes.
add a comment |
Maybe using inotifywait in the /proc/[0-9]+ directories would let you have a better glimpse of short run processes.
Maybe using inotifywait in the /proc/[0-9]+ directories would let you have a better glimpse of short run processes.
answered Jun 7 '14 at 11:34
pirouxpiroux
1
1
add a comment |
add a comment |
Looking at the challenge this method of attack would assume that you can run a script and watch what runs on the box, so I would write a script that simply does a dump of ps -eaf every couple of seconds, this would catch a cron, eventually, since crons run once every minute.
This vector of attack would require you to watch for this script running, note the location of the script, and dig in deeper.
Isn't that pretty much the one-liner I posted in the question?
– Cybergibbons
Jun 9 '14 at 8:13
@Cybergibbons - more or less. I'd modify the script slightly and there are other ways to watch for processes running, so if this wasn't successful in finding any cronjobs, I might dig in deeper with those.
– slm♦
Jun 9 '14 at 11:58
add a comment |
Looking at the challenge this method of attack would assume that you can run a script and watch what runs on the box, so I would write a script that simply does a dump of ps -eaf every couple of seconds, this would catch a cron, eventually, since crons run once every minute.
This vector of attack would require you to watch for this script running, note the location of the script, and dig in deeper.
Isn't that pretty much the one-liner I posted in the question?
– Cybergibbons
Jun 9 '14 at 8:13
@Cybergibbons - more or less. I'd modify the script slightly and there are other ways to watch for processes running, so if this wasn't successful in finding any cronjobs, I might dig in deeper with those.
– slm♦
Jun 9 '14 at 11:58
add a comment |
Looking at the challenge this method of attack would assume that you can run a script and watch what runs on the box, so I would write a script that simply does a dump of ps -eaf every couple of seconds, this would catch a cron, eventually, since crons run once every minute.
This vector of attack would require you to watch for this script running, note the location of the script, and dig in deeper.
Looking at the challenge this method of attack would assume that you can run a script and watch what runs on the box, so I would write a script that simply does a dump of ps -eaf every couple of seconds, this would catch a cron, eventually, since crons run once every minute.
This vector of attack would require you to watch for this script running, note the location of the script, and dig in deeper.
answered Jun 7 '14 at 12:31
slm♦slm
251k67529685
251k67529685
Isn't that pretty much the one-liner I posted in the question?
– Cybergibbons
Jun 9 '14 at 8:13
@Cybergibbons - more or less. I'd modify the script slightly and there are other ways to watch for processes running, so if this wasn't successful in finding any cronjobs, I might dig in deeper with those.
– slm♦
Jun 9 '14 at 11:58
add a comment |
Isn't that pretty much the one-liner I posted in the question?
– Cybergibbons
Jun 9 '14 at 8:13
@Cybergibbons - more or less. I'd modify the script slightly and there are other ways to watch for processes running, so if this wasn't successful in finding any cronjobs, I might dig in deeper with those.
– slm♦
Jun 9 '14 at 11:58
Isn't that pretty much the one-liner I posted in the question?
– Cybergibbons
Jun 9 '14 at 8:13
Isn't that pretty much the one-liner I posted in the question?
– Cybergibbons
Jun 9 '14 at 8:13
@Cybergibbons - more or less. I'd modify the script slightly and there are other ways to watch for processes running, so if this wasn't successful in finding any cronjobs, I might dig in deeper with those.
– slm♦
Jun 9 '14 at 11:58
@Cybergibbons - more or less. I'd modify the script slightly and there are other ways to watch for processes running, so if this wasn't successful in finding any cronjobs, I might dig in deeper with those.
– slm♦
Jun 9 '14 at 11:58
add a comment |
In this specific case, the file is located on /var/spool/cron/crontabs/flag03, and you can read it with the nebula account.
But level03 doesn't have enough privileges to access it.
add a comment |
In this specific case, the file is located on /var/spool/cron/crontabs/flag03, and you can read it with the nebula account.
But level03 doesn't have enough privileges to access it.
add a comment |
In this specific case, the file is located on /var/spool/cron/crontabs/flag03, and you can read it with the nebula account.
But level03 doesn't have enough privileges to access it.
In this specific case, the file is located on /var/spool/cron/crontabs/flag03, and you can read it with the nebula account.
But level03 doesn't have enough privileges to access it.
answered Mar 12 '15 at 15:59
thiagowfxthiagowfx
736413
736413
add a comment |
add a comment |
Which version of Ubuntu? If it's using systemd, you could rely on the cron cgroup created by systemd I guess, as all processes started by cron will be a direct child.
One of the option to get this information is to use the ps command with something like:
ps -eo user,pid,cmd,unit | grep cron.service | grep flag03
Why does this not suffer from the same issue as the suggestion in the question i.e. short lived processes will be missed.
– Cybergibbons
Dec 20 '16 at 14:39
Indeed, but you could mix that with the idea from @piroux and add a inotify watch on the files in/sys/fs/cgroup/systemd/system.slice/cron.service/
– Bigon
Dec 20 '16 at 15:27
add a comment |
Which version of Ubuntu? If it's using systemd, you could rely on the cron cgroup created by systemd I guess, as all processes started by cron will be a direct child.
One of the option to get this information is to use the ps command with something like:
ps -eo user,pid,cmd,unit | grep cron.service | grep flag03
Why does this not suffer from the same issue as the suggestion in the question i.e. short lived processes will be missed.
– Cybergibbons
Dec 20 '16 at 14:39
Indeed, but you could mix that with the idea from @piroux and add a inotify watch on the files in/sys/fs/cgroup/systemd/system.slice/cron.service/
– Bigon
Dec 20 '16 at 15:27
add a comment |
Which version of Ubuntu? If it's using systemd, you could rely on the cron cgroup created by systemd I guess, as all processes started by cron will be a direct child.
One of the option to get this information is to use the ps command with something like:
ps -eo user,pid,cmd,unit | grep cron.service | grep flag03
Which version of Ubuntu? If it's using systemd, you could rely on the cron cgroup created by systemd I guess, as all processes started by cron will be a direct child.
One of the option to get this information is to use the ps command with something like:
ps -eo user,pid,cmd,unit | grep cron.service | grep flag03
edited Dec 11 '16 at 12:08
mazs
2,5921623
2,5921623
answered Dec 11 '16 at 11:35
BigonBigon
1,257713
1,257713
Why does this not suffer from the same issue as the suggestion in the question i.e. short lived processes will be missed.
– Cybergibbons
Dec 20 '16 at 14:39
Indeed, but you could mix that with the idea from @piroux and add a inotify watch on the files in/sys/fs/cgroup/systemd/system.slice/cron.service/
– Bigon
Dec 20 '16 at 15:27
add a comment |
Why does this not suffer from the same issue as the suggestion in the question i.e. short lived processes will be missed.
– Cybergibbons
Dec 20 '16 at 14:39
Indeed, but you could mix that with the idea from @piroux and add a inotify watch on the files in/sys/fs/cgroup/systemd/system.slice/cron.service/
– Bigon
Dec 20 '16 at 15:27
Why does this not suffer from the same issue as the suggestion in the question i.e. short lived processes will be missed.
– Cybergibbons
Dec 20 '16 at 14:39
Why does this not suffer from the same issue as the suggestion in the question i.e. short lived processes will be missed.
– Cybergibbons
Dec 20 '16 at 14:39
Indeed, but you could mix that with the idea from @piroux and add a inotify watch on the files in
/sys/fs/cgroup/systemd/system.slice/cron.service/– Bigon
Dec 20 '16 at 15:27
Indeed, but you could mix that with the idea from @piroux and add a inotify watch on the files in
/sys/fs/cgroup/systemd/system.slice/cron.service/– Bigon
Dec 20 '16 at 15:27
add a comment |
You can't. The closest you can get is:
inotifywait -m /home/flag03/script
That won't show execution but it will show when script is opened or accessed.
add a comment |
You can't. The closest you can get is:
inotifywait -m /home/flag03/script
That won't show execution but it will show when script is opened or accessed.
add a comment |
You can't. The closest you can get is:
inotifywait -m /home/flag03/script
That won't show execution but it will show when script is opened or accessed.
You can't. The closest you can get is:
inotifywait -m /home/flag03/script
That won't show execution but it will show when script is opened or accessed.
answered May 3 '18 at 23:53
Mark WagnerMark Wagner
1,35667
1,35667
add a comment |
add a comment |
while true; do ps aux | egrep -v "grep|tail|aux" | tail -n 1; sleep 1; done
3
Give more info, it is a Q&A site and not a snippet sharing one.
– peterh
Dec 11 '16 at 7:52
add a comment |
while true; do ps aux | egrep -v "grep|tail|aux" | tail -n 1; sleep 1; done
3
Give more info, it is a Q&A site and not a snippet sharing one.
– peterh
Dec 11 '16 at 7:52
add a comment |
while true; do ps aux | egrep -v "grep|tail|aux" | tail -n 1; sleep 1; done
while true; do ps aux | egrep -v "grep|tail|aux" | tail -n 1; sleep 1; done
edited Dec 11 '16 at 20:36
slm♦
251k67529685
251k67529685
answered Dec 11 '16 at 5:44
RobRob
1
1
3
Give more info, it is a Q&A site and not a snippet sharing one.
– peterh
Dec 11 '16 at 7:52
add a comment |
3
Give more info, it is a Q&A site and not a snippet sharing one.
– peterh
Dec 11 '16 at 7:52
3
3
Give more info, it is a Q&A site and not a snippet sharing one.
– peterh
Dec 11 '16 at 7:52
Give more info, it is a Q&A site and not a snippet sharing one.
– peterh
Dec 11 '16 at 7:52
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f134800%2fdetecting-cron-tasks-run-by-another-user%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Can you look at anything under
/var/log/? Look for log messages about cron tasks.– slm♦
Jun 6 '14 at 18:09
No, unfortunately no permissions or not relevant (grep -ri cron / or find / -name cron)
– Cybergibbons
Jun 6 '14 at 19:15