※ lynx란?
요즘처럼 Graphical한 Browser가 나오기 전에 사용하던 Text Browser로 배치작업으로 웹페이지의
내용을 가져올때 사용하면 편리하다.

※ 원하는 작업
한 회사의 FTP 서버로 FTP 접속을 초당 수십회 정도 로그인 시도를 한다면 이는 분명 누군가가
해당 사이트에 대해 공격을 하는 것으로 볼 수 있으며, 해당 아이피가 어디에 속해 있는지 알고 싶다.

- FTP Log에서 Login 시도 IP를 걸러내는 작업은 각자에게 맡기고..

- IP가 포함된 파일이 hack.txt라면

################## 시작 ##################
for a in `cat hack.txt`
do
echo "IP Address : $a"
# 다음 두줄로 보이는 내용은 한줄에 입력해야 한다.
echo "whoistype=I&domain=$a&x=33&y=8" | lynx -post_data -source http://WHOIS서버주소/검색URL |
         egrep "(기관명|Org Name)"|grep ":"
# 위의 두줄로 보이는 내용은 한줄에 입력해야 한다.
echo "=="
sleep 10
done
################## 끝 ##################

한줄로 입력해야 한다는 줄의 "whoistype~y=8" 부분은 Proxy Tool을 이용하여 POST로 넘겨주는 데이터의
일반형을 구해야 한다.

※ 내용이 약간 설렁 설렁 한 것 같은데... 사용법을 잘 연구해 보시길...
※ 중요한 것은 echo "POST DATA" | lynx -post_data -source... 이 부분이다.

반응형
Posted by She쥐포s
o 쉘도라도 닷 컴
    - 좋은 코딩의 예
    - 스크립트 예제
    - 쉘관련 링크
    - Tip과 Trick 등 여러가지 읽을거리가 많이 있다.

http://www.shelldorado.com
반응형
Posted by She쥐포s
                      Unix Tip 2521 - November 26, 2005
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

디렉토리 구조 재생성하기

복잡한 디렉토리 구조를 가진 장비가 있고, 이 디렉토리 구조를 다른 장비에
복사하려 한다.

예를 들어 테스트 목적으로 퍼미션과, UID/GID와 디렉토리 구조는
복사하되 사용자의 파일은 복사하지 않는다고 가정한다.

가장 빠른 솔루션은 다음과 같다.

machine_a # cd /mydir
machine_a # find . -depth -print | cpio -o -O /tmp/dir.cpio

dir.cpio를 다른 장비에 복사한다.

machine_b # mkdir /mydir ; cd /mydir
machine_b # cat /tmp/dir.cpio | cpio -id
반응형
Posted by She쥐포s

2007. 11. 3. 21:12 Unix

디렉토리 내용 옮기기

디렉토리 내용 옮기기
(Solaris에서.. 다른 Unix도 대동소이함, 리눅스의 경우 S옵션도 있음 찾아볼 것)
 
cd origdir
tar cfb - 126k . | ( cd /newdir ; tar xfvp - )

성능을 위해서는 star가 더 좋다.
ufsdump와 restore에 대해서는 man page를 보라, 매우 비슷한 문법이다.
):
@@@@@@@@@@@@@@@@@@@@[ 원문 ]@@@@@@@@@@@@@@@@@@@@
 
cd origdir
tar cfb - 126k . | ( cd /newdir ; tar xfvp - )

for performance star is better
see man pages for ufsdump+restore, very similar syntax
):
반응형
Posted by She쥐포s
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                             UNIX GURU UNIVERSE
                                UNIX HOT TIP
 
                       Unix Tip 2327 - May 16, 2006
 
                   http://www.ugu.com/sui/ugu/show?tip.today
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
cpio로 디렉토리구조(tree) 복사하기
 
표준 Unix tar를 사용하여 디렉토리구조를 복사하게 되면 원래의 복사하는 동안
디렉토리와 파일에 대한 소유자와 그룹정보를 보존하지 않는다.
이 정보를 보존하기 위해서 다음과 같은 방법으로 find(1)와 pipe를 통해
cpio(1)를 사용하라.
 
% cd <원본 디렉토리>
% find . -depth -print | cpio -pudm <대상 디렉토리>
 
이 명령은 <원본 디렉토리>의 디렉토리 구조에 대한 미러 이미지를 <대상 디렉토리>에
생성할 것이다.
 
@@@@@@@@@@@@@@@@@@@@[ 원문 ]@@@@@@@@@@@@@@@@@@@@
 
COPY A TREE WITH CPIO
 
Using standard UNIX tar to copy a
tree doesn't preserve the original
owner and group information for the
directories and files during the copy.
To do this, use find(1) piped to cpio(1)
this way:
 
% cd <source-directory>
% find . -depth -print | cpio -pudm <dest-directory>
 
This will create a mirror image of the
<source-directory> tree in <dest-directory>.
반응형
Posted by She쥐포s

2007. 11. 3. 21:08 Unix

strings 명령어

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                             UNIX GURU UNIVERSE
                                UNIX HOT TIP

                       Unix Tip 2340 - May 29, 2006

                   
http://www.ugu.com/sui/ugu/show?tip.today
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

strings

오브젝트 파일(바이너리 파일)의 내용을 확인하기 위해서 vi 또는 cat 명령을 사용할
수 없다, 그렇게 하기 위해 strings 명령을 사용하라.

%  strings [바이너리 파일명]

명령은 오브젝트 파일에 있는 모든 인쇄 가능한 문자를 화면에 출력할 것이다.
기본적으로 strings 명령은 실행파일의 ASCII 문자를 찾아 화면에 출력한다.
 
core 파일과 다른 바이너리 에러 파일에 유용하다.

@@@@@@@@@@@@@@@@@@@@[ 원문 ]@@@@@@@@@@@@@@@@@@@@

STRINGS - OLD BUT A GOODIE

To check content of an object
file(binary file ) we can't use vi
or cat command, for that use strings
command.

%  strings [name of binary file]

It will print all the printable strings
present in object file.  Basically
strings command looks for ASCII strings
in executable file and print it.

Great for core files and other binary
error files
 
This tip generously supported by: aggarami@pcsbom.patni.com
반응형
Posted by She쥐포s

2007. 11. 3. 21:06 Unix

at으로 매일 실행하기

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                             UNIX GURU UNIVERSE
                                UNIX HOT TIP

                       Unix Tip 2339 - May 28, 2006

                   
http://www.ugu.com/sui/ugu/show?tip.today
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

at으로 매일 실행하기

유닉스는 지정된 시간에 따라 작업을 실행할 수 있는 "at"이라는 명령어를 제공한다.

특정한 작업을 매시간, 매일 실행하기 위해서는 매일 재귀적으로 실행될 수 있는
"at.sh"라는 파일에 다음의 명령어들을 사용하라.

########### CUT HERE ##################

#! /usr/bin/sh

# dt는 현재 날짜를 저장하는데 사용하는 변수

dt=`date | cut -c5-10`

# tm은 현재 시간을 저장하는데 사용하는 변수

tm=`date | cut -c12-13`

while [ $tm -le 23 ]
do

#
"at"은 명령어이고 -f는 특정파일을 실행하는데 사용하는 옵션이다.
# "file Name"은 실행가능한 파일이어야 한다.

    at -f  ./"file Name" $tm $dt
    tm=`expr $tm + 1`
done

#
인위적인 개입없이, 자동으로 다음날의 작업 스케줄을 변경한다.

at -f ./"File Name" 2358 $dt
dt=`expr $dt + 1`
at -f ./at.sh 0002 $dt

########### CUT HERE ##################
 
@@@@@@@@@@@@@@@@@@@@[ 원문 ]@@@@@@@@@@@@@@@@@@@@
 
RUN DAILY WITH AT

UNIX provides a command called "at" which can be used to run jobs according
to the specfied time.

To run a particular job in every hour, every day use the following set of
commands in a file called "at.sh" which will be executed recursively everyday.

########### CUT HERE ##################

#! /usr/bin/sh

# dt is a variable used to store current date

dt=`date | cut -c5-10`

# tm is a variable used to store current time

tm=`date | cut -c12-13`

while [ $tm -le 23 ]
do

# "at" is the command ad -f is the option used to execute a specified
# file. "file Name" should be an executable file.

 at -f  ./"file Name" $tm $dt
 tm=`expr $tm + 1`
done

# With out manual intervention, automatic change over to the next day's job
# scheduling

at -f ./"File Name" 2358 $dt
dt=`expr $dt + 1`
at -f ./at.sh 0002 $dt

########### CUT HERE ##################
반응형
Posted by She쥐포s

2007. 11. 3. 21:05 Unix

숨김파일 찾기

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                             UNIX GURU UNIVERSE
                                UNIX HOT TIP

                       Unix Tip 2338 - May 27, 2006

                   
http://www.ugu.com/sui/ugu/show?tip.today
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

숨김파일 찾기
 
디렉토리에서 숨김파일(.으로 시작하는)만을 찾는다.

ls -a | grep "^\."
 
또는
 
ls -a | awk '$0~/^\./ {print $0}'

@@@@@@@@@@@@@@@@@@@@[ 원문 ]@@@@@@@@@@@@@@@@@@@@

FIND THOSE HIDDEN FILES

Finding only hidden files
(starting with .) in a directory.

ls -a | grep "^\." OR
ls -a | awk '$0~/^\./ {print $0}'
반응형
Posted by She쥐포s

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                             UNIX GURU UNIVERSE
                                UNIX HOT TIP

                       Unix Tip 2337 - May 26, 2006

                   
http://www.ugu.com/sui/ugu/show?tip.today
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
마지막 일요일에 실행하기

매월 마지막 일요일에 작업을 실행하려면, cron으로 다음의 문법을 사용할 있다.

 

18 * * * 0 [`date "+%d"` -gt 24] && /path/to/script

 

이 명령은 일요일 18시에 날짜가 24보다 큰지 체크하여 24보다 크다면 작업을

실행하라(만일 23을 지정하면 작업은 매월 마지막 2 일요일에 실행될 것이다)는

의미이다.


주: date 명령을 감싸고 있는 '`'는 작은 따옴표(')가 아니다.(~와 함께 있는 기호)

=====================================================

RUN ON LAST SUNDAY

If you want a job to run on the last
sunday of every month, you can use
the following syntax from within cron:

18 * * * 0 [`date "+%d"` -gt 24] && /path/to/script

i.e. on sundays at 18:00 check if
the day of the month is greater than
24 - if so run the job (if 23 is
specified the job will run on the last
2 sundays of the month)

NOTE: There back-ticks around the date
command, not single quotes.

This tip generously supported by: duncan.ferguson@egg.com

반응형
Posted by She쥐포s

2007. 11. 3. 20:59 Unix

확장자 바꾸기

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                             UNIX GURU UNIVERSE
                                UNIX HOT TIP
 
                       Unix Tip 2334 - May 23, 2006
 
                   http://www.ugu.com/sui/ugu/show?tip.today
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
확장자 바꾸기
 
여러 파일들의 확장자를 변경하고자 할때 다음의 명령어로는 수행할 수 없다.
 
       % mv *.abc *.def
 
하지만 다음 쉘 스크립트를 이용하여 원하는 작업을 하는데 사용할 수 있다.
 
***
 
다음 쉘 스크립트를 이용하면 확장자가 .abc인 파일(*.abc)을 모두
확장자가 .def인 파일(*.def)변경할 수 있다.
 
#!/bin/sh
for f in *.abc; do
    mv $f `basename $f .abc`.def
done
 
스크립트가 어떻게 작동하는지 살펴보자.
 
for f in *.abc; do
 
.abc로 끝나는 파일을 찾아 순서대로 파일명을 $F에 대입한다.
 
 mv $f `basename $f.abc`.def
 
`basename $f .abc`는 $f의 파일명을 받아 따라오는 .abc를 떼어내고,
.def를 앞의 결과에 덧붙이면 결과적으로 명령은 다음과 같이 된다.
 
"mv file.abc file.def"
 
done
 
위의 "for" 루프를 종료한다.
 
"csh" 또는 "tcsh"에서 위의 작업을 하려면 다음과 같이 할 수 있다.
 
foreach f in ( *.abc )
   mv $f `basename $f .abc`.def
end
 
----------------------------------------------------------
 
CHANGE THE SUFFIX
 
If you want to change the suffix of multiple files, you can't do:
 
       % mv *.abc *.def
 
However the following shell script can be used to do the required
opperation:
 
***
 
Change all *.abc file to *.def the following shell script would work:
 
#!/bin/sh
for f in *.abc; do
 mv $f `basename $f .abc`.def
done
 
How it works:
 
 for f in *.abc; do
 
Set up a look for all files ending in .abc, and each time around setup
$f as the filename
 
 mv $f `basename $f.abc`.def
 
`basename $f .abc` takes the filename in $f and removes any trailing
occurences of .abc, we then append .def to the result and the resulting
command becomes
"mv file.abc file.def"
 
  done
 
Ends the "for" loop above.
 
Under "csh" or "tcsh" a similar thing could be done with:
 
 foreach f in ( *.abc )
   mv $f `basename $f .abc`.def
 end
 
This tip generously supported by: pwain@liberate.com
반응형
Posted by She쥐포s
이전버튼 1 2 이전버튼

블로그 이미지
She쥐포s
Yesterday
Today
Total

달력

 « |  » 2024.4
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

최근에 올라온 글

최근에 달린 댓글

글 보관함