diff --git a/saker/api/fofa.py b/saker/api/fofa.py new file mode 100644 index 0000000..7cc7a1b --- /dev/null +++ b/saker/api/fofa.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import json +import requests + +from saker.utils.encode import b64e + + +class Fofa(object): + + url = "https://fofa.so/api/" + + def __init__(self, email, key): + super(Fofa, self).__init__() + self.s = requests.Session() + self.email = email + self.key = key + + def search(self, query, page=1, size=100, full="false"): + qbase64 = b64e(query) + api = "v1/search/all" + params = { + "qbase64": qbase64, + "page": page, + "size": size, + "full": full, + "email": self.email, + "key": self.key, + } + r = self.s.get(self.url + api, params=params) + data = json.loads(r.text) + return data diff --git a/saker/api/githubapi.py b/saker/api/githubapi.py index 24635fe..db92fef 100644 --- a/saker/api/githubapi.py +++ b/saker/api/githubapi.py @@ -145,13 +145,3 @@ def gatherParameter(self): for parameter in datas: print(parameter) parameters[parameter] += 1 - break - - -if __name__ == '__main__': - token = '' - g = GithubAPI(token) - # print(g.gatherByEmail('@github.com')) - # g.gatherParameter() - # g.getUsersByOrgContributors('') - # g.dumpUsersInfo() diff --git a/test/api/githubapi.py b/test/api/githubapi.py new file mode 100644 index 0000000..d2d514e --- /dev/null +++ b/test/api/githubapi.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import unittest + +from saker.api.githubapi import GithubAPI + + +class GithubTest(unittest.TestCase): + + def test_main(self): + token = '' + g = GithubAPI(token) + print(g.gatherByEmail('@github.com')) + # g.gatherParameter() + # g.getUsersByOrgContributors('') + # g.dumpUsersInfo() + + +if __name__ == '__main__': + unittest.main()