Скачиваний:
12
Добавлен:
01.05.2014
Размер:
2.67 Кб
Скачать
echo "This is the program for lr1 "
echo "Formats of executeble files "
echo "Press <Enter> to continue..."
read
clear
echo
echo "Menu:"

echo "1. List of ELF Files"
echo "2. Print entry point and some asm commands for file"
echo "3. Print list of sections for file"
echo "4. Check string in .dynstr section in file"
echo "5. Compile strings from .dynstr section from all files in directory"
echo "6. Print list of READONLY sections and them size"
echo "7. For ELF file print list of und symbols"
echo "8. For ELF file print some strings asm from addres if section executable and ERROR if no"
echo "Enter choose"
read choose

case $choose in
1) file -s * | grep ELF;;

2) echo "Enter filename"
read filename
objdump -d --start-address=`objdump -f $filename | awk '{if ( $1 == "start") $3 }'` $filename;;
3) echo "Enter filename"
read filename
readelf -S $filename | grep '^ \[[0-9|| ]' | awk '{ if ( ($1 == "[") && ($2 != "0]")) { print $3;} else { if ($1 != "[") print $2; } }';;
4) echo "Enter filename"
read filename
echo "Enter String"
read stri
numberS=`readelf -S $filename | grep '.dynstr'| awk '{ if($1 =="[") { print substr($STR,5,1)}
else {
print substr($STR,4,2)
}
}'`;
readelf --hex-dump=$numberS $filename | grep $stri ;;
5) echo "Enter dirname"
read dirname
for m in `file -s $dirname* | grep ELF | awk '{ print $1}'| tr -d ":" `
do
echo $m;
numberS=`readelf -S $m | grep '.dynstr'| awk '{ if($1 =="[")
{ print substr($STR,5,1)}
else {
print substr($STR,4,2)
}
}'`;

readelf --hex-dump= $numberS >> out.txt;

done;;
6) echo "Enter filename"
read filename
readelf -S $filename | awk '{ if (($8 !~ /XW/) && ($7 !~ /XW/) )
{
if ($1 ~ /]/) {

print $6;

}
else {

print $7;
}
}
}'| grep '[0-9]'> summ.txt;
summ=0;
for m in `grep "" summ.txt`
do
num1=`hex2dec $m`;
summ=`expr $summ + $num1`
done
echo -n "Sum = ";
echo $summ;;
7) echo "Enter filename"
read filename
readelf -s $filename | grep -w UND ;;
8) echo "Enter filename"
read filename
echo "Enter addr"
read addr
readelf -S $filename | awk '{ if (($8 ~ /X/) || ($7 ~ /X/))
{
if ($1 ~ /]/) {
print $4;
}
else {
print $5;
}
}
}'|grep $addr > summ.txt;
num=`cat summ.txt`;
if [ $addr = $num ];
then {
startNum=`echo -n "0x"; echo $addr`;
objdump -d --start-address=$startNum $filename | head;
} else
echo "Error";
fi;;
*) echo Error!;;
esac

read
#cd $DNAME
#ls -X > /home/yaroslav/l2.txt
#file -f /home/yaroslav/l2.txt
#rm /home/yaroslav/Desktop/l1.txt
#cd /home/yaroslav/Desktop
Соседние файлы в папке Лабораторная работа №11