因為有個單位是使用自行申請的ADSL
近來每天都打電話來說網路被鎖
在想說要不要寫個程式在user開机時把ip傳來同時在黑名單把ip刪掉
先找了一些資料
找出目前使用的ip
curl icanhazip.com
curl ipv4.icanhazip.com
wget -qO- icanhazip.com
在批次檔中使用ftp傳檔
ftp -s:upload.txt
upload.txt內容
open ftp.server.com
user@server.com
userpwd
prompt
cd ftp_upload
mput test.txt
bye
使用python拿到ip並寄出
import urllib2,smtplib,sys
response = urllib2.urlopen('http://icanhazip.com/')
html = response.read()
print html
sender = "test_from_hinet@hinet.net"
receipt = "abc@de.com"
smtp = smtplib.SMTP("168.95.4.10")
header = "Subject: ip \r\n\r\n"
msg = html
smtp.sendmail(sender, receipt, header+msg)
smtp.quit()
http://neochung.com/2015/01/pc/batch-file/windows%E4%B8%AD%E4%BD%BF%E7%94%A8%E6%89%B9%E6%AC%A1%E6%AA%94-bat-%E4%B8%8A%E5%82%B3ftp%E6%AA%94%E6%A1%88/
http://askubuntu.com/questions/95910/command-for-determining-my-public-ip
沒有留言:
張貼留言