Giter Club home page Giter Club logo

ecx-api-client's Introduction

ecx-api-client

A PHP library for interacting with the APWG eCX API

Fully supports all features of the eCX API.

See the docs for more information.

To install via composer, add the following to your composer.json:

{
	"repositories":[
		{
			"type":"git",
			"url":"https://github.com/APWG/ecx-api-client"
		}
	],
	"require":{
		"apwg/ecx-api-client": "dev-master"
	}
}

To install without composer, clone this repo on disk and execute a composer install under the repository root to install the needed dependencies. You can then autoload the library and it's dependencies via require_once($pathToClient . "/vendor/autoload.php");

Example script to write a time ranged and confidence filtered list to a file in csv (uses nategood/commando for cli options):

#!/usr/bin/env php
<?php
require_once(__DIR__ . '/vendor/autoload.php');

$command = new \Commando\Command();
$command->option('token')->aka('t')->required(TRUE)->description('Your eCX API token');
$command->option('dd_date_start')->aka('s')->required(TRUE)->description('The starting epoch timestamp');
$command->option('dd_date_end')->aka('e')->required(TRUE)->description('The ending epoch timestamp');
$command->option('confidence_level')->aka('c')->required(TRUE)->description('The confidence level');
$command->option('base_uri')->aka('b')->required(TRUE)->description('The base APWG API uri');
$command->option('out')->aka('o')->required(TRUE)->description('The path to the output file to write the csv data to');

$client = new \APWG\API\Phish\PhishClient($command['base_uri'], $command['token']);

$headers = [
	'url',
	'brand',
	'confidence_level',
	'date_discovered',
];

println(implode(',', $headers), $command['out']);

$i = 0;
$toBreak = FALSE;
while ($toBreak == FALSE) {
	echo "[*] pulling page " . $i . PHP_EOL;
	$data = json_decode($client->search([
		'dd_date_start'    => $command['dd_date_start'],
		'dd_date_end'      => $command['dd_date_end'],
		'confidence_level' => $command['confidence_level'],
		'page'             => $i,
		'fields'           => implode(',', $headers)
	])->getBody()->getContents(), TRUE);
	if ($data['current_count'] < 500) {
		$toBreak = TRUE;
		if ($data['current_count'] == 0) {
			continue;
		}
	}
	foreach ($data['_embedded']['phish'] as $phish) {
		println(implode(',', [
			'"' . $phish['url'] . '"',
			'"' . $phish['brand'] . '"',
			$phish['confidence_level'],
			gmdate(DATE_ATOM, $phish['date_discovered']),
		]), $command['out']);
	}
	$i++;
}


function println($string, $file) {
	file_put_contents($file, $string . PHP_EOL, FILE_APPEND);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.