diff --git a/apiserver/report/handler/saas_method_pool_handler.py b/apiserver/report/handler/saas_method_pool_handler.py index e1a96b5..832be29 100644 --- a/apiserver/report/handler/saas_method_pool_handler.py +++ b/apiserver/report/handler/saas_method_pool_handler.py @@ -19,7 +19,7 @@ from apiserver import utils from apiserver.report.handler.report_handler_interface import IReportHandler from apiserver.report.report_handler_factory import ReportHandler - +import gzip logger = logging.getLogger('dongtai.openapi') @@ -151,7 +151,8 @@ def save_method_call(self, pool_sign, current_version_agents): query_params=self.http_query_string, http_protocol=self.http_protocol) method_pool.res_header = utils.base64_decode(self.http_res_header) - method_pool.res_body = self.http_res_body + method_pool.res_body = decode_content( + self.http_res_body, get_content_encoding(self.http_req_header)) method_pool.uri_sha1 = self.sha1(self.http_uri) method_pool.save(update_fields=[ 'update_time', @@ -225,3 +226,25 @@ def sha1(raw): h = sha1() h.update(raw.encode('utf-8')) return h.hexdigest() + + +def decode_content(body, content_type): + if content_type == 'gzip': + try: + return gzip.decompress(bytes(body, encoding='utf-8')) + except: + logger.error('not gzip type but using gzip as content_encoding') + return body + return body + + +def get_content_encoding(header): + headers = SaasMethodPoolHandler.parse_headers(header) + for header in headers: + try: + k, v = header.strip().split(':') + if k.lower() == 'content-encoding': + return v + except: + pass + return '' diff --git a/test/apiserver/test_agent_method_pool.py b/test/apiserver/test_agent_method_pool.py index efcf663..88c1e4c 100644 --- a/test/apiserver/test_agent_method_pool.py +++ b/test/apiserver/test_agent_method_pool.py @@ -10,7 +10,7 @@ from test.apiserver.test_agent_base import AgentTestCase,gzipdata from dongtai.models.agent import IastAgent from dongtai.models.agent_method_pool import MethodPool - +import gzip class AgentMethodPoolTestCase(AgentTestCase): @@ -349,3 +349,714 @@ def test_agent_method_pool_upload(self): assert response.status_code == 200 res = MethodPool.objects.filter(agent_id=self.agent_id).all() assert len(res) == 1 + + def test_agent_method_pool_from_go_agent(self): + data = { + "type": 36, + "detail": { + "agentId": + 4025, + "disk": + "", + "memory": + "", + "cpu": + "", + "methodQueue": + 0, + "replayQueue": + 0, + "reqCount": + 0, + "reportQueue": + 0, + "packagePath": + "", + "packageSignature": + "", + "packageName": + "", + "packageAlgorithm": + "", + "uri": + "/sqli1", + "url": + "http://localhost:9999/sqli123132123313132321123231", + "protocol": + "HTTP/1.1", + "contextPath": + "", + "pool": [{ + "invokeId": + 40252101640145388, + "interfaces": [], + "targetHash": + ["824634910755", "824634910761", "0", "0", "0", "0"], + "targetValues": + "Level low ", + "signature": + "go-agent/core/httpRequestCookie.Cookie(0xc00014e100, {0x8420f8, 0x5})\n", + "originClassName": + "http.(*Request)", + "sourceValues": + "Level ", + "methodName": + "Cookie", + "className": + "http.(*Request)", + "source": + True, + "callerLineNumber": + 49, + "callerClass": + "github.com/govwa/util", + "args": + "[\"Level\"]", + "callerMethod": + "GetCookie(0xc00014e100, {0x8420f8, 0x5})\n", + "sourceHash": ["8659192"], + "retClassName": + "*http.Cookie " + }, { + "invokeId": + 40252101640145389, + "interfaces": [], + "targetHash": [ + "824634288360", "824634288368", "824634288378", + "824634288384", "824634288396", "824634288400", + "824634288416", "0" + ], + "targetValues": + "root Aa@6447985 govwa localhost 3306 http://localhost 9999 ", + "signature": + "go-agent/core/jsonUnmarshal.Unmarshal({0xc000324200, 0xd9, 0x200}, {0x79e520, 0xc0001da580})\n", + "originClassName": + "fmt", + "sourceValues": + "", + "methodName": + "Sprintf", + "className": + "fmt", + "source": + True, + "callerLineNumber": + 29, + "callerClass": + "github.com/govwa/util/config", + "args": + "[\"ewogICAgInVzZXIiOiAicm9vdCIsCiAgICAicGFzc3dvcmQiOiAiQWFANjQ0Nzk4NSIsCiAgICAiZGJuYW1lIjogImdvdndhIiwKICAgICJzcWxob3N0IjogImxvY2FsaG9zdCIsCiAgICAic3FscG9ydCI6ICIzMzA2IiwKICAgICJ3ZWJzZXJ2ZXIiOiAiaHR0cDovL2xvY2FsaG9zdCIsCiAgICAid2VicG9ydCI6ICI5OTk5IiwKCiAgICAic2Vzc2lvbmtleToiOiAiRzBWdzQ0NCIKfQ==\"]", + "callerMethod": + "LoadConfig()\n", + "sourceHash": + None, + "retClassName": + "*config.Config " + }, { + "invokeId": + 40252101640145390, + "interfaces": [], + "targetHash": ["824636572896"], + "targetValues": + "root:Aa@6447985@tcp(localhost:3306)/ ", + "signature": + "go-agent/core/fmtSprintf.Sprintf({0x84afe4, 0x11}, {0xc00032c4b8, 0x4, 0x4})\n", + "originClassName": + "fmt", + "sourceValues": + "%s:%s@tcp(%s:%s)/ root Aa@6447985 localhost 3306 ", + "methodName": + "Sprintf", + "className": + "fmt", + "source": + False, + "callerLineNumber": + 18, + "callerClass": + "github.com/govwa/util/database", + "args": + "[\"%s:%s@tcp(%s:%s)/\",[\"root\",\"Aa@6447985\",\"localhost\",\"3306\"]]", + "callerMethod": + "Connect()\n", + "sourceHash": [ + "8695780", "824634288360", "824634288368", + "824634288384", "824634288396" + ], + "retClassName": + "string " + }, { + "invokeId": + 40252101640145391, + "interfaces": [], + "targetHash": ["824636573472"], + "targetValues": + "root:Aa@6447985@tcp(localhost:3306)/govwa ", + "signature": + "go-agent/core/fmtSprintf.Sprintf({0x84c9df, 0x13}, {0xc00032c4f8, 0x5, 0x5})\n", + "originClassName": + "fmt", + "sourceValues": + "%s:%s@tcp(%s:%s)/%s root Aa@6447985 localhost 3306 govwa ", + "methodName": + "Sprintf", + "className": + "fmt", + "source": + False, + "callerLineNumber": + 30, + "callerClass": + "github.com/govwa/util/database", + "args": + "[\"%s:%s@tcp(%s:%s)/%s\",[\"root\",\"Aa@6447985\",\"localhost\",\"3306\",\"govwa\"]]", + "callerMethod": + "Connect()\n", + "sourceHash": [ + "8702431", "824634288360", "824634288368", + "824634288384", "824634288396", "824634288378" + ], + "retClassName": + "string " + }, { + "invokeId": + 40252101640145390, + "interfaces": [], + "targetHash": + ["824634910484", "824634910490", "0", "0", "0", "0"], + "targetValues": + "govwa MTY0MDE0NDg3NHxEdi1CQkFFQ180SUFBUkFCRUFBQVh2LUNBQU1HYzNSeWFXNW5EQThBRFdkdmRuZGhYM05sYzNOcGIyNEVZbTl2YkFJQ0FBRUdjM1J5YVc1bkRBY0FCWFZ1WVcxbEJuTjBjbWx1Wnd3SEFBVmhaRzFwYmdaemRISnBibWNNQkFBQ2FXUUdjM1J5YVc1bkRBTUFBVEU9fPfvm5eU0A5drQKDLDOgC_ffWcZue0sMf7EbJ7H5XzIj ", + "signature": + "go-agent/core/httpRequestCookie.Cookie(0xc00014e100, {0x8424b8, 0x5})\n", + "originClassName": + "http.(*Request)", + "sourceValues": + "govwa ", + "methodName": + "Cookie", + "className": + "http.(*Request)", + "source": + True, + "callerLineNumber": + 91, + "callerClass": + "github.com/gorilla/sessions.(*CookieStore)", + "args": + "[\"govwa\"]", + "callerMethod": + "New(0xc0000b6ce0, 0xc00014e100, {0x8424b8, 0x5})\n", + "sourceHash": ["8660152"], + "retClassName": + "*http.Cookie " + }, { + "invokeId": + 40252101640145391, + "interfaces": [], + "targetHash": + ["824634910748", "824634910752", "0", "0", "0", "0"], + "targetValues": + "Uid 1 ", + "signature": + "go-agent/core/httpRequestCookie.Cookie(0xc00014e100, {0x8413f6, 0x3})\n", + "originClassName": + "http.(*Request)", + "sourceValues": + "Uid ", + "methodName": + "Cookie", + "className": + "http.(*Request)", + "source": + True, + "callerLineNumber": + 49, + "callerClass": + "github.com/govwa/util", + "args": + "[\"Uid\"]", + "callerMethod": + "GetCookie(0xc00014e100, {0x8413f6, 0x3})\n", + "sourceHash": ["8655862"], + "retClassName": + "*http.Cookie " + }, { + "invokeId": 40252101640145392, + "interfaces": [], + "targetHash": ["824635081280"], + "targetValues": + "SELECT p.user_id, p.full_name, p.city, p.phone_number \n\t\t\t\t\t\t\t\tFROM Profile as p,Users as u \n\t\t\t\t\t\t\t\twhere p.user_id = u.id \n\t\t\t\t\t\t\t\tand u.id=1 ", + "signature": + "go-agent/core/fmtSprintf.Sprintf({0x86883b, 0x90}, {0xc00032c6c0, 0x1, 0x1})\n", + "originClassName": "fmt", + "sourceValues": + "SELECT p.user_id, p.full_name, p.city, p.phone_number \n\t\t\t\t\t\t\t\tFROM Profile as p,Users as u \n\t\t\t\t\t\t\t\twhere p.user_id = u.id \n\t\t\t\t\t\t\t\tand u.id=%s 1 ", + "methodName": "Sprintf", + "className": "fmt", + "source": False, + "callerLineNumber": 38, + "callerClass": + "github.com/govwa/vulnerability/sqli.(*Profile)", + "args": + "[\"SELECT p.user_id, p.full_name, p.city, p.phone_number \\n\\t\\t\\t\\t\\t\\t\\t\\tFROM Profile as p,Users as u \\n\\t\\t\\t\\t\\t\\t\\t\\twhere p.user_id = u.id \\n\\t\\t\\t\\t\\t\\t\\t\\tand u.id=%s\",[\"1\"]]", + "callerMethod": + "UnsafeQueryGetData(0xc0002925c0, {0xc000122820, 0x1})\n", + "sourceHash": ["8816699", "824634910752"], + "retClassName": "string " + }, { + "invokeId": 40252101640145393, + "interfaces": [], + "targetHash": None, + "targetValues": "", + "signature": + "go-agent/core/sqlDBQuery.Query(0xc0001c0a90, {0xc00014c240, 0x8f}, {0x0, 0x0, 0x0})\n", + "originClassName": "sql.(*DB)", + "sourceValues": + "SELECT p.user_id, p.full_name, p.city, p.phone_number \n\t\t\t\t\t\t\t\tFROM Profile as p,Users as u \n\t\t\t\t\t\t\t\twhere p.user_id = u.id \n\t\t\t\t\t\t\t\tand u.id=1 ", + "methodName": "Query", + "className": "sql.(*DB)", + "source": False, + "callerLineNumber": 42, + "callerClass": + "github.com/govwa/vulnerability/sqli.(*Profile)", + "args": + "[\"SELECT p.user_id, p.full_name, p.city, p.phone_number \\n\\t\\t\\t\\t\\t\\t\\t\\tFROM Profile as p,Users as u \\n\\t\\t\\t\\t\\t\\t\\t\\twhere p.user_id = u.id \\n\\t\\t\\t\\t\\t\\t\\t\\tand u.id=1\",None]", + "callerMethod": + "UnsafeQueryGetData(0xc0002925c0, {0xc000122820, 0x1})\n", + "sourceHash": ["824635081280"], + "retClassName": "*sql.Rows *errors.errorString " + }], + "language": + "GO", + "clientIp": + "[::1]:53457", + "secure": + False, + "queryString": + "", + "replayRequest": + False, + "method": + "GET", + "reqHeader": + "eyJBY2NlcHQiOlsidGV4dC9odG1sLGFwcGxpY2F0aW9uL3hodG1sK3htbCxhcHBsaWNhdGlvbi94bWw7cT0wLjksaW1hZ2Uvd2VicCxpbWFnZS9hcG5nLCovKjtxPTAuOCxhcHBsaWNhdGlvbi9zaWduZWQtZXhjaGFuZ2U7dj1iMztxPTAuOSJdLCJBY2NlcHQtRW5jb2RpbmciOlsiZ3ppcCwgZGVmbGF0ZSwgYnIiXSwiQWNjZXB0LUxhbmd1YWdlIjpbInpoLUNOLHpoO3E9MC45LGVuLUdCO3E9MC44LGVuO3E9MC43LGVuLVVTO3E9MC42Il0sIkNvbm5lY3Rpb24iOlsia2VlcC1hbGl2ZSJdLCJDb29raWUiOlsiSG1fbHZ0XzY5YmUxNTIzNTFlNDc5YjhiNjRmNzdhOTM0NzAzYTU1PTE2Mzk3MjcwNjA7IGdvdndhPU1UWTBNREUwTkRnM05IeEVkaTFDUWtGRlExODBTVUZCVWtGQ1JVRkJRVmgyTFVOQlFVMUhZek5TZVdGWE5XNUVRVGhCUkZka2RtUnVaR2hZTTA1c1l6Tk9jR0l5TkVWWmJUbDJZa0ZKUTBGQlJVZGpNMUo1WVZjMWJrUkJZMEZDV0ZaMVdWY3hiRUp1VGpCamJXeDFXbmQzU0VGQlZtaGFSekZ3WW1kYWVtUklTbkJpYldOTlFrRkJRMkZYVVVkak0xSjVZVmMxYmtSQlRVRkJWRVU5ZlBmdm01ZVUwQTVkclFLRExET2dDX2ZmV2NadWUwc01mN0ViSjdINVh6SWo7IFVpZD0xOyBMZXZlbD1sb3ciXSwiUmVmZXJlciI6WyJodHRwOi8vbG9jYWxob3N0Ojk5OTkvc3FsaTEiXSwiU2VjLUNoLVVhIjpbIlwiIE5vdCBBO0JyYW5kXCI7dj1cIjk5XCIsIFwiQ2hyb21pdW1cIjt2PVwiOTZcIiwgXCJNaWNyb3NvZnQgRWRnZVwiO3Y9XCI5NlwiIl0sIlNlYy1DaC1VYS1Nb2JpbGUiOlsiPzAiXSwiU2VjLUNoLVVhLVBsYXRmb3JtIjpbIlwiV2luZG93c1wiIl0sIlNlYy1GZXRjaC1EZXN0IjpbImRvY3VtZW50Il0sIlNlYy1GZXRjaC1Nb2RlIjpbIm5hdmlnYXRlIl0sIlNlYy1GZXRjaC1TaXRlIjpbInNhbWUtb3JpZ2luIl0sIlNlYy1GZXRjaC1Vc2VyIjpbIj8xIl0sIlVwZ3JhZGUtSW5zZWN1cmUtUmVxdWVzdHMiOlsiMSJdLCJVc2VyLUFnZW50IjpbIk1vemlsbGEvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0LzUzNy4zNiAoS0hUTUwsIGxpa2UgR2Vja28pIENocm9tZS85Ni4wLjQ2NjQuMTEwIFNhZmFyaS81MzcuMzYgRWRnLzk2LjAuMTA1NC42MiJdfQ==", + "reqBody": + "", + "resBody": + " \u003cp\u003eYour Profile :\u003c/p\u003e\n sql: converting argument $1 type: unsupported type []interface {}, a slice of interface \n\u003cpre\u003e\nUid : 1\nName : \nCity : \nNumber : \n\u003c/pre\u003e\n \u003cdiv class=\"more-info\"\u003e\n \u003cspan\u003eMore Info :\u003c/span\u003e\n \u003ca target=\"_blank\" href=\"http://www.sqlinjection.net/union/\"\u003ehttp://www.sqlinjection.net/union/\u003c/a\u003e\n \u003ca target=\"_blank\" href=\"https://www.owasp.org/index.php/SQL_Injection\"\u003ehttps://www.owasp.org/index.php/SQL_Injection\u003c/a\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n \u003cfooter class=\"footer\"\u003e\n \u003cdiv class=\"container\"\u003e\n \u003cspan\u003e\u003ci class=\"fa fa-copyright\"\u003e\u003c/i\u003eNemosecurity\u003c/span\u003e\n \u003c/div\u003e\n \u003c/footer\u003e\n\u003c/div\u003e\n\n\u003c/body\u003e\n\n\u003c/html\u003e\n \u003cli\u003e\u003ca href=\"idor1\"\u003eIDOR 1\u003c/a\u003e\u003c/li\u003e\n \u003cli\u003e\u003ca href=\"idor2\"\u003eIDOR 2\u003c/a\u003e\u003c/li\u003e\n \u003c/ul\u003e\n\n \n \u003cli\u003e\n \u003ca href=\"csa\"\u003e\n \u003ci class=\"fa fa-bug fa-lg\"\u003e\u003c/i\u003e Client Side Auth\n \u003c/a\u003e\n \u003c/li\u003e\n \u003cli style=\"height:35px\"\u003e\n \u003c/li\u003e\n \u003cli\u003e\n \u003ca href=\"setting\"\u003e\n \u003ci class=\"glyphicon glyphicon-cog fa-lg\"\u003e\u003c/i\u003e Setting\n \u003c/a\u003e\n \u003c/li\u003e\n \u003cli\u003e\n \u003ca href=\"logout\"\u003e\n \u003ci class=\"fa fa-sign-out fa-lg\"\u003e\u003c/i\u003e Logout\n \u003c/a\u003e\n \u003c/li\u003e\n \n \u003c/ul\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \n\u003cdiv class=\"col-md-9\"\u003e\n \u003cdiv class=\"panel panel-primary\"\u003e\n \u003cdiv class=\"panel-heading\"\u003eSQL Injection Vulnerability\u003c/div\u003e\n \u003cdiv class=\"panel-body\"\u003e\n \u003cdiv class=\"pnl\"\u003e\n \n \u003cp\u003eThis should be safe\u003c/p\u003e\n ", + "scheme": + "", + "resHeader": + "e30=", + "invokeId": + 0, + "interfaces": + None, + "targetHash": + None, + "targetValues": + "", + "signature": + "", + "originClassName": + "", + "sourceValues": + "", + "methodName": + "", + "className": + "", + "source": + False, + "callerLineNumber": + 0, + "callerClass": + "", + "args": + "", + "callerMethod": + "", + "sourceHash": + None, + "retClassName": + "", + "log": + "", + "apiData": + None + }, + "invoke_id": 40252101640145387 + } + data['detail']['agentId'] = self.agent_id + data = gzipdata(data) + response = self.client.post('http://testserver/api/v1/report/upload', + data=data, + HTTP_CONTENT_ENCODING='gzip', + content_type='application/json', + ) + assert response.status_code == 200 + assert MethodPool.objects.filter( + url="http://localhost:9999/sqli123132123313132321123231", + agent_id=self.agent_id).exists() + def test_agent_method_pool_gzip_test(self): + data = { + "type": 36, + "detail": { + "agentId": + 4025, + "disk": + "", + "memory": + "", + "cpu": + "", + "methodQueue": + 0, + "replayQueue": + 0, + "reqCount": + 0, + "reportQueue": + 0, + "packagePath": + "", + "packageSignature": + "", + "packageName": + "", + "packageAlgorithm": + "", + "uri": + "/sqli1", + "url": + "http://localhost:9999/sqli123132123313132321123231test", + "protocol": + "HTTP/1.1", + "contextPath": + "", + "pool": [{ + "invokeId": + 40252101640145388, + "interfaces": [], + "targetHash": + ["824634910755", "824634910761", "0", "0", "0", "0"], + "targetValues": + "Level low ", + "signature": + "go-agent/core/httpRequestCookie.Cookie(0xc00014e100, {0x8420f8, 0x5})\n", + "originClassName": + "http.(*Request)", + "sourceValues": + "Level ", + "methodName": + "Cookie", + "className": + "http.(*Request)", + "source": + True, + "callerLineNumber": + 49, + "callerClass": + "github.com/govwa/util", + "args": + "[\"Level\"]", + "callerMethod": + "GetCookie(0xc00014e100, {0x8420f8, 0x5})\n", + "sourceHash": ["8659192"], + "retClassName": + "*http.Cookie " + }, { + "invokeId": + 40252101640145389, + "interfaces": [], + "targetHash": [ + "824634288360", "824634288368", "824634288378", + "824634288384", "824634288396", "824634288400", + "824634288416", "0" + ], + "targetValues": + "root Aa@6447985 govwa localhost 3306 http://localhost 9999 ", + "signature": + "go-agent/core/jsonUnmarshal.Unmarshal({0xc000324200, 0xd9, 0x200}, {0x79e520, 0xc0001da580})\n", + "originClassName": + "fmt", + "sourceValues": + "", + "methodName": + "Sprintf", + "className": + "fmt", + "source": + True, + "callerLineNumber": + 29, + "callerClass": + "github.com/govwa/util/config", + "args": + "[\"ewogICAgInVzZXIiOiAicm9vdCIsCiAgICAicGFzc3dvcmQiOiAiQWFANjQ0Nzk4NSIsCiAgICAiZGJuYW1lIjogImdvdndhIiwKICAgICJzcWxob3N0IjogImxvY2FsaG9zdCIsCiAgICAic3FscG9ydCI6ICIzMzA2IiwKICAgICJ3ZWJzZXJ2ZXIiOiAiaHR0cDovL2xvY2FsaG9zdCIsCiAgICAid2VicG9ydCI6ICI5OTk5IiwKCiAgICAic2Vzc2lvbmtleToiOiAiRzBWdzQ0NCIKfQ==\"]", + "callerMethod": + "LoadConfig()\n", + "sourceHash": + None, + "retClassName": + "*config.Config " + }, { + "invokeId": + 40252101640145390, + "interfaces": [], + "targetHash": ["824636572896"], + "targetValues": + "root:Aa@6447985@tcp(localhost:3306)/ ", + "signature": + "go-agent/core/fmtSprintf.Sprintf({0x84afe4, 0x11}, {0xc00032c4b8, 0x4, 0x4})\n", + "originClassName": + "fmt", + "sourceValues": + "%s:%s@tcp(%s:%s)/ root Aa@6447985 localhost 3306 ", + "methodName": + "Sprintf", + "className": + "fmt", + "source": + False, + "callerLineNumber": + 18, + "callerClass": + "github.com/govwa/util/database", + "args": + "[\"%s:%s@tcp(%s:%s)/\",[\"root\",\"Aa@6447985\",\"localhost\",\"3306\"]]", + "callerMethod": + "Connect()\n", + "sourceHash": [ + "8695780", "824634288360", "824634288368", + "824634288384", "824634288396" + ], + "retClassName": + "string " + }, { + "invokeId": + 40252101640145391, + "interfaces": [], + "targetHash": ["824636573472"], + "targetValues": + "root:Aa@6447985@tcp(localhost:3306)/govwa ", + "signature": + "go-agent/core/fmtSprintf.Sprintf({0x84c9df, 0x13}, {0xc00032c4f8, 0x5, 0x5})\n", + "originClassName": + "fmt", + "sourceValues": + "%s:%s@tcp(%s:%s)/%s root Aa@6447985 localhost 3306 govwa ", + "methodName": + "Sprintf", + "className": + "fmt", + "source": + False, + "callerLineNumber": + 30, + "callerClass": + "github.com/govwa/util/database", + "args": + "[\"%s:%s@tcp(%s:%s)/%s\",[\"root\",\"Aa@6447985\",\"localhost\",\"3306\",\"govwa\"]]", + "callerMethod": + "Connect()\n", + "sourceHash": [ + "8702431", "824634288360", "824634288368", + "824634288384", "824634288396", "824634288378" + ], + "retClassName": + "string " + }, { + "invokeId": + 40252101640145390, + "interfaces": [], + "targetHash": + ["824634910484", "824634910490", "0", "0", "0", "0"], + "targetValues": + "govwa MTY0MDE0NDg3NHxEdi1CQkFFQ180SUFBUkFCRUFBQVh2LUNBQU1HYzNSeWFXNW5EQThBRFdkdmRuZGhYM05sYzNOcGIyNEVZbTl2YkFJQ0FBRUdjM1J5YVc1bkRBY0FCWFZ1WVcxbEJuTjBjbWx1Wnd3SEFBVmhaRzFwYmdaemRISnBibWNNQkFBQ2FXUUdjM1J5YVc1bkRBTUFBVEU9fPfvm5eU0A5drQKDLDOgC_ffWcZue0sMf7EbJ7H5XzIj ", + "signature": + "go-agent/core/httpRequestCookie.Cookie(0xc00014e100, {0x8424b8, 0x5})\n", + "originClassName": + "http.(*Request)", + "sourceValues": + "govwa ", + "methodName": + "Cookie", + "className": + "http.(*Request)", + "source": + True, + "callerLineNumber": + 91, + "callerClass": + "github.com/gorilla/sessions.(*CookieStore)", + "args": + "[\"govwa\"]", + "callerMethod": + "New(0xc0000b6ce0, 0xc00014e100, {0x8424b8, 0x5})\n", + "sourceHash": ["8660152"], + "retClassName": + "*http.Cookie " + }, { + "invokeId": + 40252101640145391, + "interfaces": [], + "targetHash": + ["824634910748", "824634910752", "0", "0", "0", "0"], + "targetValues": + "Uid 1 ", + "signature": + "go-agent/core/httpRequestCookie.Cookie(0xc00014e100, {0x8413f6, 0x3})\n", + "originClassName": + "http.(*Request)", + "sourceValues": + "Uid ", + "methodName": + "Cookie", + "className": + "http.(*Request)", + "source": + True, + "callerLineNumber": + 49, + "callerClass": + "github.com/govwa/util", + "args": + "[\"Uid\"]", + "callerMethod": + "GetCookie(0xc00014e100, {0x8413f6, 0x3})\n", + "sourceHash": ["8655862"], + "retClassName": + "*http.Cookie " + }, { + "invokeId": 40252101640145392, + "interfaces": [], + "targetHash": ["824635081280"], + "targetValues": + "SELECT p.user_id, p.full_name, p.city, p.phone_number \n\t\t\t\t\t\t\t\tFROM Profile as p,Users as u \n\t\t\t\t\t\t\t\twhere p.user_id = u.id \n\t\t\t\t\t\t\t\tand u.id=1 ", + "signature": + "go-agent/core/fmtSprintf.Sprintf({0x86883b, 0x90}, {0xc00032c6c0, 0x1, 0x1})\n", + "originClassName": "fmt", + "sourceValues": + "SELECT p.user_id, p.full_name, p.city, p.phone_number \n\t\t\t\t\t\t\t\tFROM Profile as p,Users as u \n\t\t\t\t\t\t\t\twhere p.user_id = u.id \n\t\t\t\t\t\t\t\tand u.id=%s 1 ", + "methodName": "Sprintf", + "className": "fmt", + "source": False, + "callerLineNumber": 38, + "callerClass": + "github.com/govwa/vulnerability/sqli.(*Profile)", + "args": + "[\"SELECT p.user_id, p.full_name, p.city, p.phone_number \\n\\t\\t\\t\\t\\t\\t\\t\\tFROM Profile as p,Users as u \\n\\t\\t\\t\\t\\t\\t\\t\\twhere p.user_id = u.id \\n\\t\\t\\t\\t\\t\\t\\t\\tand u.id=%s\",[\"1\"]]", + "callerMethod": + "UnsafeQueryGetData(0xc0002925c0, {0xc000122820, 0x1})\n", + "sourceHash": ["8816699", "824634910752"], + "retClassName": "string " + }, { + "invokeId": 40252101640145393, + "interfaces": [], + "targetHash": None, + "targetValues": "", + "signature": + "go-agent/core/sqlDBQuery.Query(0xc0001c0a90, {0xc00014c240, 0x8f}, {0x0, 0x0, 0x0})\n", + "originClassName": "sql.(*DB)", + "sourceValues": + "SELECT p.user_id, p.full_name, p.city, p.phone_number \n\t\t\t\t\t\t\t\tFROM Profile as p,Users as u \n\t\t\t\t\t\t\t\twhere p.user_id = u.id \n\t\t\t\t\t\t\t\tand u.id=1 ", + "methodName": "Query", + "className": "sql.(*DB)", + "source": False, + "callerLineNumber": 42, + "callerClass": + "github.com/govwa/vulnerability/sqli.(*Profile)", + "args": + "[\"SELECT p.user_id, p.full_name, p.city, p.phone_number \\n\\t\\t\\t\\t\\t\\t\\t\\tFROM Profile as p,Users as u \\n\\t\\t\\t\\t\\t\\t\\t\\twhere p.user_id = u.id \\n\\t\\t\\t\\t\\t\\t\\t\\tand u.id=1\",None]", + "callerMethod": + "UnsafeQueryGetData(0xc0002925c0, {0xc000122820, 0x1})\n", + "sourceHash": ["824635081280"], + "retClassName": "*sql.Rows *errors.errorString " + }], + "language": + "GO", + "clientIp": + "[::1]:53457", + "secure": + False, + "queryString": + "", + "replayRequest": + False, + "method": + "GET", + "reqHeader": + "eyJBY2NlcHQiOlsidGV4dC9odG1sLGFwcGxpY2F0aW9uL3hodG1sK3htbCxhcHBsaWNhdGlvbi94bWw7cT0wLjksaW1hZ2Uvd2VicCxpbWFnZS9hcG5nLCovKjtxPTAuOCxhcHBsaWNhdGlvbi9zaWduZWQtZXhjaGFuZ2U7dj1iMztxPTAuOSJdLCJBY2NlcHQtRW5jb2RpbmciOlsiZ3ppcCwgZGVmbGF0ZSwgYnIiXSwiQWNjZXB0LUxhbmd1YWdlIjpbInpoLUNOLHpoO3E9MC45LGVuLUdCO3E9MC44LGVuO3E9MC43LGVuLVVTO3E9MC42Il0sIkNvbm5lY3Rpb24iOlsia2VlcC1hbGl2ZSJdLCJDb29raWUiOlsiSG1fbHZ0XzY5YmUxNTIzNTFlNDc5YjhiNjRmNzdhOTM0NzAzYTU1PTE2Mzk3MjcwNjA7IGdvdndhPU1UWTBNREUwTkRnM05IeEVkaTFDUWtGRlExODBTVUZCVWtGQ1JVRkJRVmgyTFVOQlFVMUhZek5TZVdGWE5XNUVRVGhCUkZka2RtUnVaR2hZTTA1c1l6Tk9jR0l5TkVWWmJUbDJZa0ZKUTBGQlJVZGpNMUo1WVZjMWJrUkJZMEZDV0ZaMVdWY3hiRUp1VGpCamJXeDFXbmQzU0VGQlZtaGFSekZ3WW1kYWVtUklTbkJpYldOTlFrRkJRMkZYVVVkak0xSjVZVmMxYmtSQlRVRkJWRVU5ZlBmdm01ZVUwQTVkclFLRExET2dDX2ZmV2NadWUwc01mN0ViSjdINVh6SWo7IFVpZD0xOyBMZXZlbD1sb3ciXSwiUmVmZXJlciI6WyJodHRwOi8vbG9jYWxob3N0Ojk5OTkvc3FsaTEiXSwiU2VjLUNoLVVhIjpbIlwiIE5vdCBBO0JyYW5kXCI7dj1cIjk5XCIsIFwiQ2hyb21pdW1cIjt2PVwiOTZcIiwgXCJNaWNyb3NvZnQgRWRnZVwiO3Y9XCI5NlwiIl0sIlNlYy1DaC1VYS1Nb2JpbGUiOlsiPzAiXSwiU2VjLUNoLVVhLVBsYXRmb3JtIjpbIlwiV2luZG93c1wiIl0sIlNlYy1GZXRjaC1EZXN0IjpbImRvY3VtZW50Il0sIlNlYy1GZXRjaC1Nb2RlIjpbIm5hdmlnYXRlIl0sIlNlYy1GZXRjaC1TaXRlIjpbInNhbWUtb3JpZ2luIl0sIlNlYy1GZXRjaC1Vc2VyIjpbIj8xIl0sIlVwZ3JhZGUtSW5zZWN1cmUtUmVxdWVzdHMiOlsiMSJdLCJVc2VyLUFnZW50IjpbIk1vemlsbGEvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0LzUzNy4zNiAoS0hUTUwsIGxpa2UgR2Vja28pIENocm9tZS85Ni4wLjQ2NjQuMTEwIFNhZmFyaS81MzcuMzYgRWRnLzk2LjAuMTA1NC42MiJdfQ==", + "reqBody": + "", + "resBody": + " \u003cp\u003eYour Profile :\u003c/p\u003e\n sql: converting argument $1 type: unsupported type []interface {}, a slice of interface \n\u003cpre\u003e\nUid : 1\nName : \nCity : \nNumber : \n\u003c/pre\u003e\n \u003cdiv class=\"more-info\"\u003e\n \u003cspan\u003eMore Info :\u003c/span\u003e\n \u003ca target=\"_blank\" href=\"http://www.sqlinjection.net/union/\"\u003ehttp://www.sqlinjection.net/union/\u003c/a\u003e\n \u003ca target=\"_blank\" href=\"https://www.owasp.org/index.php/SQL_Injection\"\u003ehttps://www.owasp.org/index.php/SQL_Injection\u003c/a\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\n \u003cfooter class=\"footer\"\u003e\n \u003cdiv class=\"container\"\u003e\n \u003cspan\u003e\u003ci class=\"fa fa-copyright\"\u003e\u003c/i\u003eNemosecurity\u003c/span\u003e\n \u003c/div\u003e\n \u003c/footer\u003e\n\u003c/div\u003e\n\n\u003c/body\u003e\n\n\u003c/html\u003e\n \u003cli\u003e\u003ca href=\"idor1\"\u003eIDOR 1\u003c/a\u003e\u003c/li\u003e\n \u003cli\u003e\u003ca href=\"idor2\"\u003eIDOR 2\u003c/a\u003e\u003c/li\u003e\n \u003c/ul\u003e\n\n \n \u003cli\u003e\n \u003ca href=\"csa\"\u003e\n \u003ci class=\"fa fa-bug fa-lg\"\u003e\u003c/i\u003e Client Side Auth\n \u003c/a\u003e\n \u003c/li\u003e\n \u003cli style=\"height:35px\"\u003e\n \u003c/li\u003e\n \u003cli\u003e\n \u003ca href=\"setting\"\u003e\n \u003ci class=\"glyphicon glyphicon-cog fa-lg\"\u003e\u003c/i\u003e Setting\n \u003c/a\u003e\n \u003c/li\u003e\n \u003cli\u003e\n \u003ca href=\"logout\"\u003e\n \u003ci class=\"fa fa-sign-out fa-lg\"\u003e\u003c/i\u003e Logout\n \u003c/a\u003e\n \u003c/li\u003e\n \n \u003c/ul\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \n\u003cdiv class=\"col-md-9\"\u003e\n \u003cdiv class=\"panel panel-primary\"\u003e\n \u003cdiv class=\"panel-heading\"\u003eSQL Injection Vulnerability\u003c/div\u003e\n \u003cdiv class=\"panel-body\"\u003e\n \u003cdiv class=\"pnl\"\u003e\n \n \u003cp\u003eThis should be safe\u003c/p\u003e\n ", + "scheme": + "", + "resHeader": + "e30=", + "invokeId": + 0, + "interfaces": + None, + "targetHash": + None, + "targetValues": + "", + "signature": + "", + "originClassName": + "", + "sourceValues": + "", + "methodName": + "", + "className": + "", + "source": + False, + "callerLineNumber": + 0, + "callerClass": + "", + "args": + "", + "callerMethod": + "", + "sourceHash": + None, + "retClassName": + "", + "log": + "", + "apiData": + None + }, + "invoke_id": 40252101640145387 + } + data['detail']['agentId'] = self.agent_id + testdata = '11231231321331232131231312233hwqeqqwe' + data['detail'][ + 'reqHeader'] = "Q29udGVudC1UeXBlPWFwcGxpY2F0aW9uL2pzb24KWC1GcmFtZS1PcHRpb25zPURFTlkKQ29udGVudC1MZW5ndGg9NjYKQ29udGVudC1lbmNvZGluZz1nemlwClgtQ29udGVudC1UeXBlLU9wdGlvbnM9bm9zbmlmZgpSZWZlcnJlci1Qb2xpY3k9c2FtZS1vcmlnaW4=" + data['detail']['resBody'] = gzip_test_data = str( + gzip.compress(bytes(testdata, encoding='utf-8'))) + data = gzipdata(data) + response = self.client.post( + 'http://testserver/api/v1/report/upload', + data=data, + HTTP_CONTENT_ENCODING='gzip', + content_type='application/json', + ) + assert response.status_code == 200 + assert MethodPool.objects.filter( + url="http://localhost:9999/sqli123132123313132321123231test", + agent_id=self.agent_id).exists() + assert MethodPool.objects.filter( + url="http://localhost:9999/sqli123132123313132321123231test", + agent_id=self.agent_id, + res_body=gzip_test_data).exists() + assert not MethodPool.objects.filter( + url="http://localhost:9999/sqli123132123313132321123231test", + agent_id=self.agent_id, + res_body=testdata).exists()