app.py 2.88 KB
Newer Older
qiuqunfeng's avatar
qiuqunfeng committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82

from flask import Flask, json, jsonify, logging

app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello, World!'

@app.route('/v3/scene/ip_reputation', methods=['GET'])
def get_data():
    from flask import request
    resource = request.args.get('resource', '')
    print(f"resource: {resource}")
    # Example data similar to your JSON structure
    data = {
        "data": [
            {
                "ioc": "159.203.93.255",
                "host": "10.65.135.204",
                "intelligence": [
                    {
                        "judgments": ["Exploit", "Spam", "Phishing", "DDoS", "APT"],
                        "severity": "low",
                        "ban": {
                            "banned": 1,
                            "reason": "The IP address belongs to DigitalOcean, LLC, it is recommended to assess and handle it accordingly."
                        },
                        "basic": {
                            "carrier": "DigitalOcean, LLC",
                            "location": {
                                "country": "美国",
                                "country_code": "US",
                                "province": "新泽西州",
                                "city": "克利夫顿",
                                "lng": -74.16366,
                                "lat": 40.858402
                            }
                        },
                        "asn": {
                            "number": "14061",
                            "info": "DIGITALOCEAN-ASN - DigitalOcean, LLC, US"
                        },
                        "tags_classes": {
                            "virus_family": [
                                "Mirai"
                            ],
                            "industry": [
                                "internet"
                            ],
                            "gangs": [
                                "APT"
                            ],
                            "tags": [
                                "APT",
                                "海莲花"
                            ],
                            "tags_type": [
                                "industry"
                            ]
                        },
                        "scene": "Residence",
                        "ioc_type": "ipv4",
                        "confidence_level": "low",
                        "is_malicious": True,
                        "source_name": "微步在线-IP信誉",
                        "update_time": 1719268503000
                    }
                ]
            }
        ],
        "response_code": 0,
        "verbose_msg": "success"
    }
    # Read JSON data from file
    with open('data/data.json', 'r', encoding='utf-8') as f:
        data = json.load(f)
        
    return jsonify(data)

if __name__ == '__main__':
    app.run(debug=True, port=8080)