awk나 sed를 이용해서 특정 구문만 출력하기?
글쓴이: i_wish_awk_sed_perl / 작성시간: 금, 2004/07/30 - 1:20오후
if(description) { script_id(10704); script_cve_id("CAN-2001-0731"); name["english"] = "Apache Directory Listing"; name["francais"] = "Apache Directory Listing"; script_name(english:name["english"], francais:name["francais"]); desc["english"] = " By making a request to the Apache web server ending in '?M=A' it is sometimes possible to obtain a directory listing even if an index.html file is present. It appears that it is possible to retrieve a directory listing from the root of the Apache web server being tested. However, this could be because there is no 'index.html' or similar default file present. Solution: Unless it is required, turn off Indexing by making the appropriate changes to your httpd.conf file. Risk Factor: Low"; script_description(english:desc["english"]); summary["english"] = "Checks to see if Apache will provide a directory listing"; script_summary(english:summary["english"]); script_category(ACT_GATHER_INFO); script_copyright(english:"This script is Copyright (C) 2001 Matt Moore", francais:"Ce script est Copyright (C) 2001 Matt Moore"); family["english"] = "CGI abuses"; family["francais"] = "Abus de CGI"; script_family(english:family["english"], francais:family["francais"]); script_dependencie("find_service.nes", "no404.nasl","http_version.nasl"); script_require_ports("Services/www", 80); script_require_keys("www/apache"); exit(0); } ... ... ...
와 같은 코드가 있습니다. nessus 의 룰파일입니다면 위의 코드에서
if(description) { ... ... ... }
로 시작되는 부분만을 출력하려고 합니다. 본래해야 하는것은 if(description) 부분에서 각각의 필드데로 짜르는것인데...일단은 파일에서 if(description) 속에 포함되어 있는 부분을 먼저 짤라야 할거 같아서요.
위의 처럼 여러 나라에 걸쳐서 있는 경우는 어떻게 해야 할지요?
그리고 awk와 sed의 차이점이라고 해야 할까요? 각각의 용도에 대해서 아직까지도 정확하게 개념이 스지 않네요.
Forums:
흠...
허접하게나마...
sed -n -e '/^if(description)/,/^}/p'
과자가 아닙니다.
cuckoo dozen, 즉.12마리의 뻐꾸기란 뜻입니다.
감사합니다. 알려 주신 방법을 이용하니 여러라인에 걸쳐 있는 부분도 제대
감사합니다. 알려 주신 방법을 이용하니 여러라인에 걸쳐 있는 부분도 제대로 골라 낼 수 있군요! ^^;
골라낸 부분에서
script_id(10704) 그리고 script_cve_id("CAN-2001-0731") 등의 몇가지 정보만을 출력 하려면 어떻게 해야 하는지요? 예을 들어
10704, CAN-2001-0731,
이런식으로 나오게 하려고 합니다. ^^*
언제쯤 정규표현식을 정복할 수 있을까? ㅡㅡ;
댓글 달기