본문 바로가기
Autohotkey/스크립트

[Autohotkey] Winhttp로 네이버 메일 보내기

by 슈퍼닷 2015. 1. 7.
반응형

 

 

 

저번에 올린 네이버 로그인에서 이번엔 그걸 이용해서 네이버 메일 보내는 스크립트를 만들어 보았습니다.

attachid부분이 보내는 사람에 따라 달라져서 구하느라 애먹었네요 ㅎㅎ

 

;;http://jogamja.tistory.com

Winhttp:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
id= 
pw=
address=
receiver=
title=
content=
if (Naver_Login(id,pw))
{
msgbox,로그인 성공
if (Naver_SendMail(id,address,receiver,title,content))
msgbox, 메일을 성공적으로 보냈습니다.
else,
msgbox, 메일을 보내는데 실패하였습니다.
}
else,
msgbox,로그인 실패

return
Naver_SendMail(user_id, user_address, receiver_address , title , content )
{
global Winhttp
url=http://mail.naver.com/json/write/send

attachurl=http://m.mail.naver.com/m/write
winhttp.open("get",attachurl)
winhttp.send
regexmatch(winhttp.responsetext,"attachID = \C(.*)\C;",attachID)

Mail:="senderName=" . user_address . "&to=" . receiver_address . "&cc=&bbc=&subject=" . title . "&body=" . content . "&contentType=html&sendSeparately=false&saveSentBox=true&type=new&fromMe=0&attachID=" . attachID1 . "&attachCount=0&attachSize=0&bigfile=0&sessionID=&seqNums=&priority=0&ndriveFileInfos=&lists=&serviceID=&bigfileCount=0&uploaderType=html5&bigfileNotice=false&bigfileHost=bigfile.mail.naver.com&u=" . user_id
winhttp.open("post",url)
Winhttp.SetRequestHeader("Referer","http://mail.naver.com")
Winhttp.SetRequestHeader("Content-Type","application/x-www-form-urlencoded")
winhttp.send(Mail)
result:=winhttp.responsetext
ifinstring,result,성공적
return true
else
return false
}

Naver_Login(user_id, user_pw)
{

 global Winhttp

FileEncoding, UTF-8
id := user_id
pw := user_pw
sc :=  ComObjCreate("ScriptControl")
sc.Language := "JavaScript"
c=0
IfNotExist,rsa.txt
{
msgbox,64,rsa.txt없음,rsa.txt가 없거나 rsa.txt가 스크립트와 같은 위치에 있지않습니다. `n 그러므로 rsa.txt를 다운받기위해 첨부파일이 있는 블로그를 실행하겠습니다.
Run,http://jogamja.tistory.com/entry/Autohotkey-Winhttp-네이버-로그인
exitapp
}
text:= "return rsa.encrypt(comVal + getLenChar(pw) + pw);"
loop,
{
FileReadLine,a,rsa.txt,%A_index%
js_script.= a   .  "`n"
if (c)
{
break
}
ifinstring,a,%text%
c++
}
sc.reset
sc.AddCode(js_script)
;// WinHttpRequest
Winhttp :=  ComObjCreate("WinHttp.WinHttpRequest.5.1")
Winhttp.Open("GET","http://static.nid.naver.com/enclogin/keys.nhn")
Winhttp.Send
res:=Winhttp.responsetext
StringSplit,SendKey,res, `,
i=1
/*
loop,4
{
msgbox,% SendKey%i%
i++
}
*/
vData =
vData .= "enctp=1"
vData .= "&encpw=" . sc.run("createRsaKey", Id, pw, SendKey1, SendKey2, SendKey3, SendKey4) 
vData .= "&encnm=" . SendKey2
vData .= "&svctype=" . "0"
vData .= "&id="
vData .= "&pw="
vData .= "&x=" . "35"
vData .= "&y=" . "14"
Winhttp.Open("POST","https://nid.naver.com/nidlogin.login")
Winhttp.SetRequestHeader("Referer","http://static.nid.naver.com/login.nhn?svc=wme&url=http%3A%2F%2Fwww.naver.com&t=20120425")
Winhttp.SetRequestHeader("Content-Type","application/x-www-form-urlencoded")
Winhttp.Send(vData)
Winhttp.WaitForResponse
txt_str := Winhttp.Responsetext
IfInString, txt_str, /sso/
 return true
else
 return false
}
;;http://jogamja.tistory.com

 

이렇게해서 네이버 메일보내기 스크립트가 완성되었습니다.

 

여기서 쓰인것들은 Winhttp가 대체적으로 쓰였고 파싱 하는 도구로서 RegExMatch와 StringSplit이 쓰였네요.

 

이런 스크립트를 만드는것은 한번 해보시면 어려운게 아닙니다.

 

스크립트를 올려놨지만 Firefox 에서 httpfox를 이용해 한번 다시 만들어보길 바랍니다.

 

그러면 나중에 코드가 바뀌어도 다시 제작하실 수 있을것입니다.

 

다음에는 Firefox의 httpfox를 이용해 여러 값을 따는 글을 올려보겠습니다.

(익스플로러 에서는 Fiddler을 쓰시면됩니다.)

 

반응형

'Autohotkey > 스크립트' 카테고리의 다른 글

[Autohotkey] Winhttp 네이버 로그인 스크립트  (4) 2015.01.05

댓글