Score:0

Is it possible to execute a script with only editing/remove/making files

in flag
Cas

Just curious,

Would you be able to run a script (let's say test.sh) without every doing ./test.sh? You can only edit/make/remove files. A few things I thought about:

  • crontab, and then add a line with the current "time + 1 minute" and the script. But crontab doesn't have a file at a location that you can edit, instead you have to edit it with crontab -e which is a command, so this one isn't an option.
  • .service file, make a service that runs the script, but then you'd have to do systemctl daemon-reload && systemctl start service to start the service, so this one also isn't an option.

Do you have an idea?

hr flag
This seems like an arbitrary distinction - is `sudo cp myscript /etc/cron.daily` a command, or is it "editing/remove/making" a file? what about `sudo nano /var/spool/cron/crontabs/someuser`?
Cas avatar
in flag
Cas
See it like I made a samba share of `/`. I can access the complete filesystem from a different device, but can only edit/remove/make files (because it's just a samba share). So `sudo cp myscript /etc/cron.daily` wouldn't be possible, but I CAN put my script there, as I have "samba access" to that folder. P.S. I haven't actually made a samba share of /, relax, it was just a good example.
FedKad avatar
cn flag
You should also explain the reasons behind this question. How is a system supposed to run a command without giving some kind of "trigger" to do it?
zwets avatar
us flag
Yes, this is possible if you had write permission for any file that is periodically or incidentally invoked (like your `.profile`). As @steeldriver points out, your user crontab or a timer unit would fit the bill. If you'd like to have it run by any other user on the system (e.g. `root`), you'll need to ask them, as we normally call this an exploit when it happens without consent.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.