如何从linux库文件中恢复cpp数据?
我不小心删除了一个 .cpp 文件,其中包含我的一些有价值的代码。 它是我自己的图书馆的一部分:libandrissh.so 我怎样才能恢复它?我尝试用手术刀,但没有找到它。
我想知道是否可以以某种方式从我的库中的 .so 或 .o 其他文件中提取信息。我认为这是可能的,因为我使用该库的程序仍然有效。
有什么建议吗? 谢谢大家
I accidentally deleted a .cpp file with some valuable code of mine.
It was part of my own library: libandrissh.so
How can I recover it? I tried scalpel, but it did not find it.
I was wondering if I could somehow extract the info from my .so or .o other files that are in my library. I think this could be possible, because my programs using the library still work.
any suggestions?
thanks guys
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果它被删除并且不在回收站或垃圾箱中,则无法从编译的二进制文件中轻松恢复它。有反汇编器可以帮助您做到这一点,但我还没有看到任何可以用于生产的反编译器可以让您回到原始来源。即使他们可以,也可能无法恢复原始符号/变量名称。
您最好的选择是查看类似 PhotoRec 的内容来搜索硬盘上的可用扇区。尽管它的名字如此,它实际上可以找到许多不同的文件格式,包括视频、音乐、文档、文本甚至 C 源文件。只要您的文件未被覆盖,您就可能能够找到它。当我妻子的文件系统损坏时,我用它从她的硬盘驱动器中恢复了大量数据。此外,它在 GPL 下是免费的。
If it's deleted and not in a recycle or trash bin you can't recover it easily from the compiled binaries. There are disassemblers to get you that far but I have not yet seen any decompilers that are production ready that can get you back to original sources. Even if they could it likely won't be able to recover the original symbol/variable names anyway.
Your best bet would be to look at something like PhotoRec to search the free sectors on your hard disk. Despite its name, it actually finds many different file formats including video, music, documents, text and even C source files. As long as your files haven't been overwritten, you will likely be able to find it. I used it to recover a lot of data from my wife's hard drive when her filesystem became corrupt. Also, it's free under the GPL.
如果你有库二进制文件,你当然可以反汇编它(例如使用 objdump --disassemble libandrissh.so ),但是从“裸”机器代码返回到更高级的语言,如 C++并不容易。我不知道有任何标准工具可以做到这一点。
if you have the library binary, you can of course disassemble it (use e.g.
objdump --disassemble libandrissh.so
), but going from the "bare" machine code back to a higher-level language like C++ is not easy. I'm not aware of any standard tools to do that.您可以尝试一些反汇编程序,例如 IDAPro
取决于所使用的编译器、标志和您可能得到的其他所有内容不错的结果。
You can try some disassembler like IDAPro
Depending on the compiler used, the flags and everything else you might get decent results.