PERL 활용..

Posted 2007/07/23 20:53 by silverbug
ps 명령어 처럼... Process List 보기..
perl -0777 -pe 'BEGIN { chdir "/proc"; @ARGV = sort { $a <=> $b } glob("*/cmdline") } $ARGV =~ m!^(\d+)/!; print "$1\t"; s/\0/ /g; $_ .= "\n";'


perl -e 'for($i=1;$i<65535;$i++){ if( -e "/proc/$i/cmdline") { $cmd=`cat /proc/$i/cmdline  |xxd -ps -c 256`; $cmd =~ s/\n//g; print $i."\t"; $uid = getpwuid((stat("/proc/$i/cwd"))[4]); $gid = getpwuid((stat("/proc/$i/cwd"))[5]); print $uid."\t".$gid."\t"; if( -e "/proc/$i/cwd"){$a=`ls -al /proc/$i/cwd`; @b = split /->/, $a; $b[1] =~ s/\n//g; $dir = $b[1];} $exe=`cat /proc/$i/cmdline`;print $exe."(".$dir." )[".$cmd."]\n";}}'

파일안의 비어있는 라인 없애기..
perl -ni.bak -e'/\S/ && print' rot.c

문자열을 바이너리로 덤프
perl -e 'printf "%08b\n", $_ for unpack "C*", shift' 'My String'

« PREV : 1 : ... 21 : 22 : 23 : 24 : 25 : 26 : 27 : 28 : 29 : ... 30 : NEXT »