我一直在尝试为android编写一个shell脚本,该脚本可以删除某些文件,以使设备稍微坚固一些,以防攻击。我想这个脚本已经在运行froyo的ubuntu上的android模拟器上运行过了。当我试图在运行4.2的windows机器上运行它时,它在底部出现错误。我已经检查了所有的目录,它们都存在。我正在使用adb运行此程序。
echo ANDROID
echo HARDENING STARTED
#removing files in the /system/xbin directory
mount -o rw,remount /dev/block/mdblock0 /system
rm /system/xbin/tcpdump
rm /system/xbin/su
#removing files in the /system/bin directory
rm /system/bin/bootanimation
rm /system/bin/dumpstate
rm /system/bin/ping
rm /system/bin/ping6
mount -o ro,remount /dev/block/mdblock0 /system
echo ANDROID
echo HARDENING COMPLETE返回此错误..我不知道发生了什么。
ANDROID
HARDENING STARTED
mount:No such file or directory
, No such file or directorytcpdump
, No such file or directorysu
, No such file or directoryootanimation
, No such file or directoryumpstate
, No such file or directorying
, No such file or directorying6
mount:No such file or directory
ANDROID
HARDENING COMPLETE请帮帮忙
瑞安
发布于 2013-01-15 20:18:27
目录/system不存在,因此您的mount命令失败。
接下来,您尝试从不存在的未挂载的/system目录中删除几个文件,这会导致更多的错误。
最后,您尝试重新挂载仍然不存在的/system,从而导致最后一个错误。
唯一的问题是错误消息有点乱码,文件名被消息以某种方式覆盖了。
编辑:回答您的其他问题...
如果你能check if the file exists,你就能正确地处理这种情况(而不是使用通配符):
# Check which device to use
if [ -e /dev/block/mdblock0 ]; then
device=/dev/block/mdblock0
elif [ -e /dev/block/mtdblock0 ]; then
device=/dev/block/mtdblock0
else
echo "Device not found";
exit 1;
fi
mount -o rw,remount $device /system
# etc...我不知道确切的Android shell命令,但假设它非常类似于bash,这应该可以工作。
发布于 2013-08-07 15:22:25
将行尾改为Unix样式,将解决您所有的问题。
https://stackoverflow.com/questions/14337513
复制相似问题