Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Defining Cookie Generator
- # HTTP Header begins with cookie
- def setcookies(user):
- username=user
- # Generating Cookie
- #
- import os
- from cgi_session import CGISession
- #
- # Genrating Random Session Key
- #
- session=CGISession()
- uuid=str(session.getID()) # This will generate random string used as key
- os.chmod('/tmp/pycgiession_%s'%(uuid),644)
- session.setParam('secure','True')
- session.setParam('username','%s'%(username))
- session.setParam('name','HTTP_COOKIE')
- session.setParam('uuid','%s'%(uuid))
- print("Set-Cookie: session_cookie \r domain = 'kali.example.com ' name = 'HTTP_COOKIE' username = %s uuid = %s ; secure = 'True'\r\n\r\n"%(username,uuid))
- ########################################################################################################
- # Getting cookies
- def getcookies():
- # Import
- import os,cgi,cgitb
- from cgi_session import CGISession # This class file uploaded here:- https://pastebin.com/L4JwHmCg
- from os import environ
- #
- cookiesDict = {}
- if 'HTTP_COOKIE' in os.environ:
- result='True'
- cookies = '%s'%os.environ['HTTP_COOKIE']
- c = cookies.split('; ')
- c_temp=[]
- usage for i in range(len(c)):
- c_temp.append(c[i].split(' '))
- c1=tuple(c_temp)
- st=c1[0]
- cookiesDict[st[4]] = st[6] #cookie name # Squencing according to the above function setcookies(user)
- cookiesDict[st[7]] = st[9] #username # This will raise error till you exec it on APACHE Server
- cookiesDict[st[10]] = st[12] #uuid
- else:
- result='False'
- return result
- return cookiesDict
- '''
- Usage:
- >>>setcookies(username)
- >>>cookies=getcookies()
- >>>cookies['username']
- test
- >>>cookies['uuid']
- 0ea3d78b80d32056a80367c74248a71a
- >>>cookies['name'] # It's just an extra entry if u wanna use it ...
- HTTP_COOKIE
- '''
- # On Server side cookie-file can be found in /tmp
Add Comment
Please, Sign In to add comment