팁이라기 보다는 문제 제기에 가깝습니다. 

리눅스에서 wget의 용도는 참 다양합니다. 
다른 홈페이지의 뭔가를 가져오고(때로는 긁어오고...) 제 경우는 내부에서 php를 실행할때로 자주 사용합니다. 

근데 man wget 하고 여러 옵션을 구경하다가 
-r 
--recursive 
라는 놈이 있어서 한번 실행을 해봤습니다. 
아예 홈페이지의 내용을 디렉토리채 긁어오는군요. 

테스트해보시려면 
wget http://www.phpschool.com -r  해보십시요. 

www.php.school.com 이라는 폴더가 하나 생기고 그 하위 폴더들이 주루룩 나오는군요. 
디렉토리 스트럭처가 적나라하게 보입니다. 
banner    community  guild    index.html  survey 
biznbaza  company    html_sub  index.php    title_image 
class    gnuboard4  images    menu_images  ttrend 

물론 php 소스가 아니고 출력된 html의 형태로 저장되기는 하지만 기타 css, js, 이미지등등은 그대로 가져오는군요. 

저만 모르고 있었던 것인가요? 
뒷북이라면 죄송합니다만.... 

여기서 하나... 
남의 홈페이지 긁어오는 데는 그만이지만 
반대로 누군가 내 홈페이지를 긁어가는 것은 기분이 엄청 나쁠 것같습니다. 

해서~~ 
아무리 생각해봐도 wget을 막기는 막아야할 것같습니다만.. 
이놈이 
-U agent-string 
--user-agent=agent-string 
옵션까지 무장을 하고 있어서 agent로 차단하는 것은 불가능해보입니다. 

혹씨나해서 살펴보니 robots.txt가 먹히는군요. 

User-agent:* 
Disallow:/ 

하니까 못 긁어가네요. 

더좋은 방법이 있는지 모르겠습니만... 
참고하시기를...

 

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

오늘도 wget 여러 옵션들을 테스트해봤습니다. 
그동안 제일 궁금했던 것이 
--user-agent=agent-string 
등으로 user-agent를 속이는데 서버에서는 어떻게 인식하는지가 제일 궁금해서 
http://browsers.garykeith.com/tools/your-browser.asp 
에 접속해봤습니다. 

 wget  --user-agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"  http://browsers.garykeith.com/tools/your-browser.asp 
했더니 튕기더군요. 
---------------------------------- 
Access Denied 
You do not appear to be using this form in accordance with my Terms of Use. 
Continued abuse will eventually result in you losing access to this server! 
It's also possible you are using security software that modifies the HTTP_REFERER header. 
If I can't confirm the referrer is valid then you can't have access to my forms. 
-------------------------------- 

그래서 이번에는 --referer 옵션까지 설정을 해서 다시 시도해봤습니다. 
wget  --user-agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"  --referer="http://browsers.garykeith.com/tools/property-docs.asp" http://browsers.garykeith.com/tools/your-browser.asp 
이번에는 성공!!! 
------------------------------- 
Your Browser 
User Agent 
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) 
.... 이하 생략 
-------------------------------- 

어찌보면 당연한 결론이지만  --user-agent, --referer 두가지다 제대로 작동합니다. 

더 무서븐것은 --save-cookie, --load-cookies,  --post-data=string, --post-file=file 입니다. 

--save-cookie "cookie.txt" --post-data "user_id=myid&password=mypassword" 
옵션을 주니까 멋있게 로그인까지 하고 쿠키를 저장해두더군요. 

다시 
 --load-cookies "cookie.txt" 하니까 회원만 가능한 곳 어디든지 정상접속됩니다. 

post.dat라는 화일에 게시판에 필요한 변수를 입력해두고 
 --load-cookies "cookie.txt"  --post-file "post.dat" 하니까 게시판에 글도 씁니다. 

잘만 활용하면 좋겠는데 
까딱하면 스팸로봇이 따로 필요없습니다...헐~~

 

출처

http://phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=62537&page=1

http://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=62631&page=1

+ Recent posts