TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Maybe: run a command, see what it does to your files without actually doing it

515 pointsby colundover 9 years ago

30 comments

paulasmuthover 9 years ago
While this looks like a nice idea on paper, I would not recommend to use the current implementation of &#x27;maybe&#x27; on a system that hosts valuable data.<p>The tool seems to work by intercepting individual &quot;blacklisted&quot; system calls and then - instead of executing them - returning a nonsense value.<p>The issue is that this breaks every single POSIX spec and will therefore break any program that does more than a few trivial IO operations and relies on those operations to behave as specified.<p>So it might work for a simple demo case where a small script only does a single file modification and never checks the results, but for any serious program (think a database, a complex on-disk format or really anything that does network IO) this will lead to corruption and undefined behaviour as system calls will return erroneous success values or invalid file descriptors.<p>I think to actually make this work one would have to emulate the system calls and make sure everything stays POSIX compliant. Doing this correctly for calls like mmap might get tricky though (and won&#x27;t be possible from within a python runtime). And even then it isn&#x27;t obvious how something like network IO would be handled.
评论 #11052605 未加载
评论 #11052450 未加载
burrowsover 9 years ago
This would be more useful if it used a virtual file system.<p>What happens if the program writes a bunch of stuff to disk then later on tries to read it?
评论 #11052183 未加载
评论 #11051607 未加载
评论 #11052254 未加载
评论 #11052693 未加载
评论 #11051415 未加载
评论 #11054831 未加载
lugus35over 9 years ago
On Windows you have sandboxie (<a href="http:&#x2F;&#x2F;www.sandboxie.com" rel="nofollow">http:&#x2F;&#x2F;www.sandboxie.com</a>), a complete sandbox for your programs.
评论 #11052203 未加载
评论 #11052484 未加载
majkeover 9 years ago
Nice idea. Shameless plug: this reminds me a ptrace hack I did a couple years back:<p>fluxcapacitor<p><a href="https:&#x2F;&#x2F;github.com&#x2F;majek&#x2F;fluxcapacitor#fluxcapacitor" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;majek&#x2F;fluxcapacitor#fluxcapacitor</a><p><a href="https:&#x2F;&#x2F;idea.popcount.org&#x2F;2013-07-19-how-to-sleep-a-million-years&#x2F;" rel="nofollow">https:&#x2F;&#x2F;idea.popcount.org&#x2F;2013-07-19-how-to-sleep-a-million-...</a>
dantillbergover 9 years ago
I&#x27;m imagining someone trying something along these lines:<p>maybe find ~&#x2F; | grep . | parallel rm {}<p>...and be fairly surprised to find everything deleted. It wasn&#x27;t find&#x27;s fault!
评论 #11051790 未加载
caioariedeover 9 years ago
Mbox does something similar, but seems to be more robust&#x2F;complete: <a href="https:&#x2F;&#x2F;pdos.csail.mit.edu&#x2F;archive&#x2F;mbox&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pdos.csail.mit.edu&#x2F;archive&#x2F;mbox&#x2F;</a>
mappuover 9 years ago
It doesn&#x27;t work this way, but my first expectation was that this would take an LVM2&#x2F;ZFS snapshot and diff the file trees afterward. Then it&#x27;d be easily ported to Windows (VSS) and wouldn&#x27;t have the subprocess issues on *BSD, but, the diff would be slower, unordered, and contain changes made by unrelated processes.
评论 #11051673 未加载
评论 #11051621 未加载
zx2c4over 9 years ago
Also check out mbox:<p><a href="https:&#x2F;&#x2F;pdos.csail.mit.edu&#x2F;archive&#x2F;mbox&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pdos.csail.mit.edu&#x2F;archive&#x2F;mbox&#x2F;</a><p>It&#x27;s a bit more complete than this.
评论 #11053138 未加载
评论 #11053068 未加载
frikover 9 years ago
Ideally, you want ad hoc sandbox (like Sandboxie on Win32)<p>Ideally, Docker could offer ad hoc commands to launch an process in a sandbox. And then you launch a file explorer process in the same sandbox (like Sandboxie) to inspect or run a diff-tool that outputs statistics like the tool in the headline.
评论 #11052177 未加载
gravypodover 9 years ago
THIS IS AMAZING! I would have never imagined seeing something this useful being made in my life.
评论 #11051903 未加载
评论 #11051420 未加载
GigabyteCoinover 9 years ago
I would have used something like this when I was first learning rsync...<p>Even though I had read all of the man pages and knew the commands inside and out, it still seemed incredibly risky and scary to me to run rsync with the --delete function when I was backing up my main USB drive for the very first time.<p>Basically my biggest fear was that I had source and destination mixed up, which I didn&#x27;t, but it would have been nice to run a test trial of that command before doing so.
评论 #11051821 未加载
评论 #11051826 未加载
评论 #11052197 未加载
rcthompsonover 9 years ago
I&#x27;d wonder if this could be implemented more robustly on ZFS using some snapshot magic.
aug-riedingerover 9 years ago
Instead of a control approach: having to confirm every little action in there, It would be nicer to have a undo-able behavior: I actually run the script on the first time, but I can easily undo it if it did not work as expected. The current state of the art is of no use for me.
rvalueover 9 years ago
I like the work but Is it possible that &quot;maybe&quot; you don&#x27;t catch something and it actually happens?
评论 #11052761 未加载
sry_not4saleover 9 years ago
I use Docker to achieve a similar thing...<p>1) Boot up a new Ubuntu docker container 2) Run command &#x2F; script 3) Use `docker diff` to see what changes to the filesystem were made<p>Obviously it&#x27;s only useful for some commands, but at least it&#x27;s safe :-)
13of40over 9 years ago
Kind of like -whatif in PowerShell, if anyone bothered to implement it right.
_Marak_over 9 years ago
This seems neat, but from a security standpoint I&#x27;d much rather see a command which spawned a new VM with a copy of my current file-system.<p>I would then want to capture all disk and network i&#x2F;o that the &quot;maybed&quot; command generated in the VM.<p>Even that wouldn&#x27;t be that secure, because the command would still be able to send sensitive data out. You could intercept the network i&#x2F;o, but that would cause most installers to fail.
txutxuover 9 years ago
Limited scope... this is local.<p>I use to implement a --trial in my shell scripts, which covers reporting of ALL operations (local and remote).<p>Anyway, this is a nice discover and nice hack.
im2w1lover 9 years ago
Suggestion: Add a way to distinguish between parameters sent to maybe and parameters sent to the program. You don&#x27;t accept any parameters at the moment, but you may want to in the future, and when you start wanting to do that, you may not want to break any existing usages by changing behavior. For that reason I think it would be good to introduce disambiguation now.
lowglowover 9 years ago
This is dope. I also wish there was better formatting&#x2F;coloring&#x2F;more info for dtruss&#x2F;ptrace in general.
评论 #11059629 未加载
markbnjover 9 years ago
Looks like a very interesting and potentially powerful diagnostic tool. Nice work!
ameliusover 9 years ago
Sadly, it is not possible to combine this tool with programs that use ptrace themselves, because of limitations in the implementation of ptrace.<p>In Linux, a program that is being ptraced is not allowed to ptrace another program.
评论 #11052531 未加载
bobp127001over 9 years ago
A really cool idea. Is this more or less how rootkits work and hide themselves? A system call is made to list the contents of a directory, and the rootkit excludes itself from that listing?
ameliusover 9 years ago
Another option is to use a filesystem with rollback capabilities.
评论 #11052718 未加载
malkaover 9 years ago
Could not it be possible with docker or like to run a command in a sandboxed environment, and then provide a diff ?
andreygrehovover 9 years ago
Would it be more safe to copy the entire target to a &#x2F;tmp and do all the required operations from there?
评论 #11052753 未加载
agumonkeyover 9 years ago
Anybody remember cleansweeper ?
tluyben2over 9 years ago
Very nice example of the python ptrace library and OS internals.
OJFordover 9 years ago
This is awesome, I hope some Mac user with the know-how sees this and is motivated to get python-ptrace on Darwin...
评论 #11052392 未加载
Mithalduover 9 years ago
I feel like this would only be useful for badly written software.<p>Anything reliable would check that its operations went through as expected and bail really early.
评论 #11051363 未加载
评论 #11051388 未加载
评论 #11051705 未加载
评论 #11051368 未加载