示例#1
0
文件: api.py 项目: cisagov/crossfeed
def intel_agg(
    query,
    date_range="YYYY-MM-DD TO YYYY-MM-DD",
    filters="{'site': ['sixgill','twitter'],'actor': ['John Doe']}",
    field="tags",
    size="10",
    recent="False",
):
    """Get aggregation of intel items via simple query."""
    url = "https://api.cybersixgill.com/intel/aggs"
    auth = token()
    headers = {
        "Content-Type": "application/json",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }
    payload = {
        "query": query,
        "date_range": date_range,
        "filters": filters,
        "field": field,
        "results_size": size,
        "recent_items": recent,
    }
    resp = requests.post(url, headers=headers, data=payload).json()
    return resp
示例#2
0
文件: api.py 项目: cisagov/crossfeed
def intel_thread_next(
    scroll_id,
    split_to_parts=False,
    custom_highlight_start_tag="@sixgill-start-highlight@",
    custom_highlight_end_tag="@sixgill-end-highlight@",
    recent_items=False,
):
    """Get a thread page content."""
    url = "https://api.cybersixgill.com/intel/intel_items/thread/next"
    auth = token()
    headers = {
        "Content-Type": "application/x-www-form-urlencoded",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }
    payload_data = {"scroll_id": scroll_id}
    payload_params = {
        "split_to_parts": split_to_parts,
        "custom_highlight_start_tag": custom_highlight_start_tag,
        "custom_highlight_end_tag": custom_highlight_end_tag,
        "recent_items": recent_items,
    }
    resp = requests.post(url,
                         headers=headers,
                         data=payload_data,
                         params=payload_params).json()
    return resp
示例#3
0
文件: api.py 项目: cisagov/crossfeed
def items_thread(
    id,
    thread_site,
    results_size=300,
    skip=0,
    highlight_query="term",
    custom_highlight_start_tag="@sixgill-start-highlight@",
    custom_highlight_end_tag="@sixgill-end-highlight@",
    scroll=False,
    split_to_parts=False,
    recent_items=False,
):
    """Get a thread page content."""
    url = "https://api.cybersixgill.com/intel/intel_items/" + id + "/thread"
    auth = token()
    headers = {
        "Content-Type": "application/x-www-form-urlencoded",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }
    payload = {
        "thread_site": thread_site,
        "results_size": results_size,
        "skip": skip,
        "highlight_query": highlight_query,
        "custom_highlight_start_tag": custom_highlight_start_tag,
        "custom_highlight_end_tag": custom_highlight_end_tag,
        "scroll": scroll,
        "split_to_parts": split_to_parts,
        "recent_items": recent_items,
    }
    resp = requests.get(url, headers=headers, params=payload).json()
    return resp
示例#4
0
文件: api.py 项目: cisagov/crossfeed
def get_organization():
    """Get list of organizations."""
    url = "https://api.cybersixgill.com/multi-tenant/organization"
    auth = token()
    headers = {
        "Content-Type": "application/json",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }
    resp = requests.get(url, headers=headers).json()
    return resp
示例#5
0
文件: api.py 项目: cisagov/crossfeed
def org_post_assets(org_id, data):
    """Get list of organizations posts."""
    url = "https://api.cybersixgill.com/multi-tenant/organization/" + org_id + "/assets"
    auth = token()
    headers = {
        "Content-Type": "application/json",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }
    resp = requests.post(url, headers=headers, json=data).json()
    return resp
示例#6
0
文件: api.py 项目: cisagov/crossfeed
def dve_acknowledge(token):
    """Get an intel item."""
    url = "https://api.cybersixgill.com/dvefeed/ioc/ack"
    auth = token()
    headers = {
        "Content-Type": "application/x-www-form-urlencoded",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }
    payload = {"X-Channel-Id": "d5cd46c205c20c87006b55a18b106428"}
    resp = requests.get(url, headers=headers, params=payload).json()
    return resp
示例#7
0
文件: api.py 项目: cisagov/crossfeed
def dve_summary(startDate, endDate):
    """Get basic Sixgill Dynamic Rating data about a specific CVE."""
    url = "https://api.cybersixgill.com/dve_enrich/summary"
    auth = token()
    headers = {
        "Content-Type": "application/x-www-form-urlencoded",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }
    payload = {"startDate": startDate, "endDate": endDate}
    resp = requests.get(url, headers=headers, params=payload).json()
    return resp
示例#8
0
文件: api.py 项目: cisagov/crossfeed
def dve_enrich(filters):
    """Enrich CVEs with Sixgill intelligence."""
    url = "https://api.cybersixgill.com/dve_enrich/enrich"
    auth = token()
    headers = {
        "Content-Type": "application/x-www-form-urlencoded",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }
    payload = {"filters": filters}
    resp = requests.post(url, headers=headers, params=payload).json()
    return resp
示例#9
0
文件: api.py 项目: cisagov/crossfeed
def dve_keyword_search(keyword, startDate, endDate):
    """Get data about a specific CVE"""
    url = "https://api.cybersixgill.com/dve_enrich/keyword_search"
    auth = token()
    headers = {
        "Content-Type": "application/x-www-form-urlencoded",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }
    payload = {"keyword": keyword, "startDate": startDate, "endDate": endDate}
    resp = requests.get(url, headers=headers, params=payload).json()
    return resp
示例#10
0
文件: api.py 项目: cisagov/crossfeed
def intel_get_item(id):
    """Get an intel item."""
    url = "https://api.cybersixgill.com/intel/intel_items/" + id
    auth = token()
    headers = {
        "Content-Type": "application/x-www-form-urlencoded",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }
    payload = {"id": id}
    resp = requests.get(url, headers=headers, params=payload).json()
    return resp
示例#11
0
文件: api.py 项目: cisagov/crossfeed
def alerts_count(organization_id):
    """Gets the total read and unread actionable alerts by organization."""
    url = "https://api.cybersixgill.com/alerts/actionable_alert/count"
    auth = token()
    headers = {
        "Content-Type": "application/json",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }
    payload = {"organization_id": organization_id}
    resp = requests.get(url, headers=headers, params=payload).json()
    return resp
示例#12
0
文件: api.py 项目: cisagov/crossfeed
def dve_top_cves(size):
    """Get data about a specific CVE"""
    url = "https://api.cybersixgill.com/dve_enrich/top_cves"
    auth = token()
    headers = {
        "Content-Type": "application/x-www-form-urlencoded",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }
    payload = {"size": size}
    resp = requests.get(url, headers=headers, params=payload).json()
    return resp
示例#13
0
文件: api.py 项目: cisagov/crossfeed
def org_assets(org_id):
    """Get list of organizations."""
    url = "https://api.cybersixgill.com/multi-tenant/organization/" + org_id + "/assets"
    auth = token()
    headers = {
        "Content-Type": "application/json",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }
    payload = {"organization_id": org_id}
    resp = requests.get(url, headers=headers, params=payload).json()
    return resp
示例#14
0
文件: api.py 项目: cisagov/crossfeed
def credential_auth(params):
    """Get data about a specific CVE"""
    url = "https://api.cybersixgill.com/credentials/leaks"
    auth = token()
    headers = {
        "Content-Type": "application/json",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }

    resp = requests.get(url, headers=headers, params=params)
    resp = resp.json()
    return resp
示例#15
0
文件: api.py 项目: cisagov/crossfeed
def alert_stats(organization_id="organization_id", threat_level="imminent"):
    """Gets actionable alerts statistics per user."""
    url = "https://api.cybersixgill.com/alerts/actionable-alert/stats"
    auth = token()
    headers = {
        "Content-Type": "application/json",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }
    payload = {
        "organization_id": organization_id,
        "threat_level": threat_level
    }
    resp = requests.patch(url, headers=headers, params=payload).json()
    return resp
示例#16
0
文件: api.py 项目: cisagov/crossfeed
def alert_patch_id(actionable_alert_id, organization_id="organization_id"):
    """Updates an actionable alert by ID."""
    url = "https://api.cybersixgill.com/alerts/actionable-alert/" + actionable_alert_id
    auth = token()
    headers = ({
        "Content-Type": "application/x-www-form-urlencoded",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }, )
    payload = {
        "actionable_alert_id": actionable_alert_id,
        "organization_id": organization_id,
    }
    resp = requests.patch(url, headers=headers, params=payload).json()
    return resp
示例#17
0
文件: api.py 项目: cisagov/crossfeed
def intel_next(scroll_id, recent_items=False):
    """Get the next batch of intel items."""
    url = "https://api.cybersixgill.com/intel/intel_items/next"
    auth = token()
    headers = {
        "Content-Type": "application/x-www-form-urlencoded",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }
    payload = {
        "scroll_id": scroll_id,
        "recent_items": recent_items,
    }
    resp = requests.post(url, headers=headers, data=payload).json()
    return resp
示例#18
0
文件: api.py 项目: cisagov/crossfeed
def alerts_list(organization_id, fetch_size, offset):
    """Get actionable alerts by ID using organization_id with optional filters."""
    url = "https://api.cybersixgill.com/alerts/actionable-alert"
    auth = token()
    headers = {
        "Content-Type": "application/json",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }
    payload = {
        "organization_id": organization_id,
        "fetch_size": fetch_size,
        "offset": offset,
    }

    resp = requests.get(url, headers=headers, params=payload)
    return resp
示例#19
0
文件: api.py 项目: cisagov/crossfeed
def intel_get(
    query,
    results_size=50,
    highlight=False,
    recent_items=False,
):
    """Get a list of intel items based on a search query."""
    url = "https://api.cybersixgill.com/intel/intel_items"
    auth = token()
    headers = {
        "Content-Type": "application/x-www-form-urlencoded",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }
    payload = {
        "query": query,
        "results_size": results_size,
        "highlight": highlight,
        "recent_items": recent_items,
    }
    resp = requests.get(url, headers=headers, params=payload).json()
    return resp
示例#20
0
文件: api.py 项目: cisagov/crossfeed
def alerts_patch(
    organization_id="organization_id",
    is_read="unread",
    threat_level="imminent",
    threat_type="type",
):
    """Updates a list of actionable alerts by ID with optional filters."""
    url = "https://api.cybersixgill.com/alerts/actionable-alert"
    auth = token()
    headers = ({
        "Content-Type": "application/x-www-form-urlencoded",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }, )
    payload = {
        "organization_id": organization_id,
        "is_read": is_read,
        "threat_level": threat_level,
        "threat_type": threat_type,
    }
    resp = requests.patch(url, headers=headers, params=payload).json()
    return resp
示例#21
0
文件: api.py 项目: cisagov/crossfeed
def intel_post(query, frm, scroll, result_size):
    """Get intel items - advanced variation."""
    url = "https://api.cybersixgill.com/intel/intel_items"
    auth = token()
    headers = {
        "Content-Type": "application/json",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }
    payload = {
        "query": query,
        "partial_content": False,
        "results_size": result_size,
        "scroll": scroll,
        "from": frm,
        "sort": "date",
        "sort_type": "desc",
        "highlight": False,
        "recent_items": False,
        "safe_content_size": True,
    }
    resp = requests.post(url, headers=headers, json=payload).json()
    return resp
示例#22
0
文件: api.py 项目: cisagov/crossfeed
def post_organization(
    name="name",
    org_com_category="category",
    countries="list_countries",
    industries="list_industries",
):
    """Adds a new organization to SixGill."""
    url = "https://api.cybersixgill.com/multi-tenant/organization"
    auth = token()
    headers = {
        "Content-Type": "application/json",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }
    payload = {
        "name": name,
        "organization_commercial_category": org_com_category,
        "countries": [countries],
        "industries": [industries],
    }
    resp = requests.post(url, headers=headers, json=payload).json()
    print(resp)
    return resp
示例#23
0
文件: api.py 项目: cisagov/crossfeed
def intel_histogram(
    query,
    date_range="YYYY-MM-DD TO YYYY-MM-DD",
    filters="{'site': ['sixgill','twitter'],'actor': ['John Doe']}",
    interval="month",
    recent_items=False,
):
    """Get date histogram of intel items."""
    url = "https://api.cybersixgill.com/intel/histogram"
    auth = token()
    headers = {
        "Content-Type": "application/json",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }
    payload = {
        "query": query,
        "date_range": date_range,
        "filters": filters,
        "interval": interval,
        "recent_items": recent_items,
    }
    resp = requests.post(url, headers=headers, json=payload).json()
    return resp
示例#24
0
文件: api.py 项目: cisagov/crossfeed
def get_content_id(
    actionable_alert_id,
    organization_id="organization_id",
    limit=100,
    highlight=False,
):
    """Gets actionable alert content by alert ID."""
    url = (
        "https://api.cybersixgill.com/alerts/actionable-alert/actionable_alert_content/"
        + actionable_alert_id)
    auth = token()
    headers = ({
        "Content-Type": "application/x-www-form-urlencoded",
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + auth,
    }, )
    payload = {
        "actionable_alert_id": actionable_alert_id,
        "organization_id": organization_id,
        "limit": limit,
        "highlight": highlight,
    }
    resp = requests.get(url, headers=headers, params=payload).json()
    return resp
示例#25
0
def main():
    updater = Updater(config.token())
    bot = Bot(config.token())
    dp = updater.dispatcher
    job = updater.job_queue

    # conversations
    # dp.add_handler(conversation.login())
    # dp.add_handler(conversation.sugerir())
    # dp.add_handler(conversation.poll())
    #
    # dp.add_handler(CallbackQueryHandler(users.button))
    # dp.add_handler(InlineQueryHandler(users.inlinequery))
    # dp.add_handler(MessageHandler(Filters.voice, users.voice_to_text))
    #
    # # entradas invalidas
    # dp.add_handler(MessageHandler(Filters.audio, users.invalid))
    # dp.add_handler(MessageHandler(Filters.document, users.invalid))
    # dp.add_handler(MessageHandler(Filters.contact, users.invalid))
    # dp.add_handler(MessageHandler(Filters.game, users.invalid))
    # dp.add_handler(MessageHandler(Filters.group, users.invalid))
    # dp.add_handler(MessageHandler(Filters.location, users.invalid))
    # dp.add_handler(MessageHandler(Filters.photo, users.invalid))
    # dp.add_handler(MessageHandler(Filters.reply, users.invalid))
    # dp.add_handler(MessageHandler(Filters.sticker, users.invalid))
    # dp.add_handler(MessageHandler(Filters.video, users.invalid))
    # dp.add_handler(MessageHandler(Filters.video_note, users.invalid))
    #
    # # erros
    # dp.add_error_handler(error_callback)
    #
    # # funções dos usuários
    # dp.add_handler(CommandHandler("start", users.start))
    # dp.add_handler(CommandHandler("deletar", users.deletar))
    # dp.add_handler(CommandHandler("notas", users.notas))
    # dp.add_handler(CommandHandler("frequencia", users.frequencia))
    # dp.add_handler(CommandHandler("horarios", users.horarios))
    # dp.add_handler(CommandHandler("historico", users.historico))
    # dp.add_handler(CommandHandler("disciplinas", users.disciplinas))
    # dp.add_handler(CommandHandler("provas", users.provas))
    # dp.add_handler(CommandHandler("curriculo", users.curriculo))
    # dp.add_handler(CommandHandler("atestado", users.atestado))
    # dp.add_handler(CommandHandler("boleto", users.boleto))
    # dp.add_handler(CommandHandler("chave", users.chave))
    # dp.add_handler(CommandHandler("moodle", users.moodle))
    # dp.add_handler(CommandHandler("email", users.emails, pass_args=True))
    # dp.add_handler(CommandHandler("comandos", users.comandos))
    # dp.add_handler(CommandHandler("ajuda", users.ajuda))
    # dp.add_handler(CommandHandler("termos", users.termos))
    dp.add_handler(CommandHandler("desenvolvedores", users.desenvolvedores))
    # dp.add_handler(CommandHandler("editais", users.editais, pass_args=True))
    # dp.add_handler(CommandHandler("noticias", users.noticias))
    # dp.add_handler(CommandHandler("minhabiblioteca", users.minhabiblioteca))
    # dp.add_handler(CommandHandler("configurar", users.configurar))
    # dp.add_handler(CommandHandler("menu", users.menu, pass_args=True))
    #
    # # funções dos administradores
    dp.add_handler(CommandHandler("users", admins.users, pass_args=True))
    dp.add_handler(CommandHandler("message", admins.message, pass_args=True))
    dp.add_handler(CommandHandler("alert", admins.alert, pass_args=True))
    dp.add_handler(
        CommandHandler("breakdown", admins.breakdown, pass_args=True))
    dp.add_handler(
        CommandHandler("suggestions", admins.suggestions, pass_args=True))
    dp.add_handler(CommandHandler("history", admins.history, pass_args=True))
    dp.add_handler(CommandHandler("chat", admins.chat, pass_args=True))
    dp.add_handler(CommandHandler("push", admins.push, pass_args=True))
    dp.add_handler(CommandHandler("results", admins.results))
    dp.add_handler(
        CommandHandler("statistics", admins.statistics, pass_args=True))
    dp.add_handler(CommandHandler("reboot", admins.reboot))
    dp.add_handler(CommandHandler("commands", admins.commands))
    dp.add_handler(CommandHandler("errors", admins.errors, pass_args=True))

    dp.add_handler(MessageHandler(Filters.text, msg_filtrada.main))
    #
    # # filtra comandos invalidos
    dp.add_handler(MessageHandler(Filters.command, msg_filtrada.unknown))
    #
    # # inicia notificação push
    # if datetime.datetime.now().hour >= 23:
    #     day = datetime.datetime.now().day + 1
    #     hour = 0
    # else:
    #     day = datetime.datetime.now().day
    #     hour = datetime.datetime.now().hour + 1
    #
    # job.run_repeating(push.notas, 1800, first=datetime.datetime.now().replace(day=day, hour=hour, minute=0, second=0, microsecond=0))
    # job.run_repeating(push.frequencia, 7200, first=datetime.datetime.now().replace(day=day, hour=hour, minute=0, second=0, microsecond=0))
    #
    admins.start(bot)
    # job.run_repeating(admins.alerta_uso, 60, first=datetime.datetime.now())

    updater.start_polling()
    updater.idle()
示例#26
0
"""
Module for interact with twitter
"""
from typing import Dict, Any, Union
import pandas as pd
from config import token, tweepy
import logging
from scipy.spatial import distance
import time

API = token()


def create_list_of_tweets(str_research, since_date):
    """
    Create a list of all tweets of since_date that you wish.

    :param str_research: name that you wish research
    :type str_research: str
    :param since_date: Date you wish research, since_date most equal the format YYY-MM-DD
    :type since_date: str
    :return: list with all information about of tweets
    :rtype: list

    """
    list_of_tweets = list()
    for tweet in tweepy.Cursor(API.search,
                               q=str_research,
                               count=100,
                               lang="pt",
                               since=since_date).items():
示例#27
0
import discord

from config import token


class MyClient(discord.Client):
    async def on_ready(self):
        print('Logged on as', self.user)

    async def on_message(self, message):
        # don't respond to ourselves
        if message.author == self.user:
            return

        if message.content == 'ping':
            await message.channel.send('pong')


client = MyClient()
client.run(token())
示例#28
0
import time
import config
import os
import tempfile
import subprocess
import random
import requests
import json
import re
from telebot import types
from telebot import util
from random import randint
from bs4 import BeautifulSoup as bs
from datetime import datetime

bot = telebot.TeleBot(config.token())

#############################################
# log                                       #
#############################################
def listener(messages):
    for m in messages:
        cid = m.chat.id
        chat_type = m.chat.type
        chat_title = m.chat.title
        now = datetime.now().strftime("%Y-%m-%d %H:%M")
        if cid > 0:
            username = m.chat.first_name
        else:
            username = m.from_user.first_name
        #[time][cid][chat_type][chat_title][username][m.text]
示例#29
0
from discord.ext.commands import Bot
from callllama import call_llama
from config import token

BOT_PREFIX = '?'
# with open('token.txt', 'r') as myfile:
#   TOKEN = str(myfile.read())

TOKEN = token('callllama')

client = Bot(command_prefix=BOT_PREFIX)

@client.command(name='callllama', description='returns llama game status')
async def callllama(game):
    await client.say(call_llama(game))

client.run(TOKEN)