内角540°

セキュリティ。SIEMとかIPSとか統計とかクラウドとか。数学以外で。

cookie

#!/usr/bin/env python
# -*- coding: utf8 -*-
import sys
import tkinter
import urllib.request ,urllib.parse
import re

root = tkinter.Tk()
v = tkinter.IntVar()
v.set(1)

def create_widgets(self):

	self.useProxyCheck = tkinter.Checkbutton(text=u'Proxyを使用(未実装)')
	self.useProxyCheck.grid(column=0, row=1)
	self.proxyAddress = tkinter.Entry(self)
	self.proxyAddress.grid(column=1, row=1)
	self.msgTargetURL = tkinter.Label(text=u'宛先URL').grid(column=0, row=2)
	self.TargetURL = tkinter.Entry(self)
	self.TargetURL.insert(tkinter.END,"https://**.jp/")
	self.TargetURL.grid(column=1, row=2)

	self.radio1 = tkinter.Radiobutton(text = u"機能1:GetHeader", variable = v, value = 1)
	self.radio1.grid(column=0, row=3)
	self.radio2 = tkinter.Radiobutton(text = u"機能2:GetCookie(未実装)", variable = v, value = 2)
	self.radio2.grid(column=1, row=3)
	self.cookieName = tkinter.Entry(self)
	self.cookieName.insert(tkinter.END,"Cookie名")
	self.cookieName.grid(column=2, row=3)

	self.msgTargetURL = tkinter.Label(text=u'grep:').grid(column=0, row=4)
	self.grepBox = tkinter.Entry(self, width=60)
	self.grepBox.grid(column=1, columnspan=3,row=4)

	self.resultBox = tkinter.Text()
	self.resultBox.grid(columnspan=4)

	self.buttonRun = tkinter.Button(text=u'Run', width=60)
	self.buttonRun.bind("<Button-1>",ShowURLHeader) 
	self.buttonRun.grid(columnspan=4)

	self.buttonClear = tkinter.Button(text=u'Clear', width=60)
	self.buttonClear.bind("<Button-1>",resultClear) 
	self.buttonClear.grid(columnspan=4)

def resultClear(event):
	root.resultBox.delete(1.0,tkinter.END)

def GetURLHeader(url):
	print(url)
	return urllib.request.urlopen(url)

def ShowURLHeader(event):
	if root.TargetURL.get() and not root.grepBox.get():
		response = GetURLHeader(root.TargetURL.get()).info()
		root.resultBox.insert(tkinter.END,response)
		root.resultBox.place()
		print(type(GetURLHeader(root.TargetURL.get())))

	elif root.TargetURL.get() and root.grepBox.get():
		pattern = re.compile(root.grepBox.get(), re.IGNORECASE)
		for line in GetURLHeader(root.TargetURL.get()).getheaders():
			line = ": ".join(line)
			if re.search(pattern,line):
				print(re.search(pattern,":".join(line)))
				root.resultBox.insert(tkinter.END,line + '\n')
				root.resultBox.place()

create_widgets(root)





root.mainloop()