LoginSignup
7
3

More than 5 years have passed since last update.

Firepower APIsを使って外部脅威情報を取り込んでみた

Last updated at Posted at 2017-12-23

この記事はシスコの同志による Advent Calendar の一部として投稿しています
https://qiita.com/advent-calendar/2017/cisco

・はじめに
Open Source IPSとして歴史のある Snortを中核にした商用 IPS/IDSである Firepowerは、多くの APIを持っています。
今回は Firepowerが持っている REST APIを利用してネットワーク設定を入れる、外部脅威情報(TXT と STIX)を取り込むことをやってみました。
オープンソース版はこちらから:https://www.snort.org/
スクリーンショット 2017-12-22 1.51.06.png

・機材と環境の説明
Firepower IPS/IDS をまとめて管理する Firepower Management Center(通称:FMC)を配置しています。
FMCは複数の Firepower IPS/IDSを管理すると共に、イベント分析、ポリシー管理、脅威情報管理の役割を担いつつ、外部と連携するための APIsを持っています。

スクリーンショット 2017-12-22 1.55.46.png

■ REST API(JSON形式)でネットワーク設定(Network Object)を入れてみる
複数台の Firepower IPS/IDSを統合管理する仕組みを持つという観点より、多くの設定が Objectという形式で使いまわせる仕組みになっています。
Objectを正しく使うことで、サブネット指定・ホスト指定・VLAN指定など検査したい範囲を定義することが可能です。
まずは REST APIを使う準備を兼ねて Obejctを作成してみます。

1.REST API Clientのインストールと起動
私の環境では定番のPOSTMANを利用します

2.FMC REST APIを使うための認証用トークン生成とドメイン情報の入手
REST APIを便利に使うために認証用トークンを生成します。また FMCはマルチドメイン対応しているため、
どのドメインに関する情報かを定義するためのドメイン情報も入手します

・REST API Clientを以下に設定
認証用トークンを生成するために、POSTする宛先は以下になります

https://<YOURFMCIP>/api/fmc_platform/v1/auth/generatetoken

・Type: Basic Authを選択
・FMC登録済みの APIまたは管理権限のある Usernameおよび Password設定
・POST実行

正しく認証用トークンが発行されると、レスポンスヘッダー内の以下情報を保存します
X-auth-access-token:
X-auth-refresh-token:
domain_uuid:
スクリーンショット 2017-12-22 2.23.12.png

3.認証用トークンを利用して Network Objectを設定
先程入手した2つのトークンと、ドメインを使って Network Objectを入れてみます

https:// <YOURFMCIP> /api/fmc_config/v1/domain/ <doimain_uuid:> /object/networks

Header部分に X-auth-access-token: と X-auth-refresh-token:をそれぞれ Key/Valueを入力
Body部分JASON形式にて Network Objectを記載

ポスト例

{
  "name": "Penetration-test-inside1",
  "value": "192.168.1.0/24",
  "overridable": false,
  "description": "Test REST API Object",
  "type": "Network"
}
{
  "name": "Penetration-test-inside2",
  "value": "192.168.2.0/24",
  "overridable": false,
  "description": "Test REST API Object",
  "type": "Network"
}

成功時のレスポンス例(ログ取得忘れたので、上記と異なる設定のレス;)

{
    "links": {
        "self": "https:// <YOURFMCIP> /api/fmc_config/v1/domain/ <doimain_uuid:> /object/networks/000C29EB-FF4E-0ed3-0000-021474836558",
        "parent": "https:// <YOURFMCIP> /api/fmc_config/v1/domain/ <doimain_uuid:> /object/networkaddresses"
    },
    "type": "Network",
    "value": "192.168.3.0/24",
    "overridable": false,
    "description": "Test REST API Object",
    "name": "Penetration-test-inside3",
    "id": "000C29EB-FF4E-0ed3-0000-021474836558",
    "metadata": {
        "timestamp": 0,
        "lastUser": {
            "name": "apiuser"
        },
        "domain": {
            "name": "Global",
            "id": "e276abec-e0f2-11e3-8169-6d9ed49b625f"
        },
        "ipType": "V_4",
        "parentType": "NetworkAddress"
    }
}

4.FMCを確認
先程POSTした Network Objectが設定されていることが確認できます

スクリーンショット 2017-12-22 17.07.40.png

今回は Network Objectの例となりましたが、実際のルール設定にも応用できます。
これで毎度同様の設定を GUI操作しなくてもOKになります。

■ 外部脅威情報をまとめたテキストで取り込んでみた
Firepower は Cisco Talosの脅威情報に基いて通信を止める・アラートをあげることが出来ます。
さらに Threat Intelligence Director(TID) という機能を使うことで、外部の脅威情報を取り込めます。
外部脅威情報を 1つ1つ設定するのは手間なので、テキストにしてまとめた脅威情報(いわゆる Blacklist IPアドレス群)を REST APIで入れてみました。
認証用トークンの手順はここでは割愛します。

・TorIPListをダウンロードして設定
ここでは検証用に置いているIPリストを使います

以下の宛先に TIDが必要とする情報をPOST

https:// <YOURFMCIP> /api/fmc_tid/v1/domain/ <doimain_uuid:> /tid/source
{
    "name": "TorIpList",
    "uri":"https://cisco.box.com/shared/static/phef4u63td7bxcgkgyt1vk5vrm461jcf.txt",
    "feedType": "flatfile",
    "feedContent": "IPV_4_ADDR",
    "delivery": "url",
    "refresh": 1440,
    "version": "1.0.0",
    "downloadOn": true,
    "params": {
        "selfSignedServerCertificate": "false",
        "hostnameVerifier": "allow_all"
    },
    "property": {
        "ttl": 90,
        "publish": true,
        "action": "monitor"
    }
}

1440秒ごとに更新される設定にしているため、静的なリンクに脅威情報を置くことで、脅威情報を自動更新できます。

スクリーンショット 2017-12-22 19.43.27.png

これで集めてきた Blacklist IPを検知したり止めることが出来るようになりました。

■ STIX/TAXIIの仕組みを利用して脅威情報を取り込んでみた
静的なリンクに脅威情報をアップロードさせるのも良いですが、世の中には脅威情報を交換するためのフォーマットや
手順の標準化が進んでいるということもありますので、その仕組みに乗っかってみました。
ここでは STIX/TAXIIを使います。

(参考情報)
STIX(Structured Threat Information eXpression)とは、脅威情報を観測事象や検知に関する脅威情報を記述した情報群です。
TAXII(Trusted Automated eXchange of Indicator Information)とは、複数宛先やピアに対して蓄積した脅威情報を交換する際に、プログラム処理できる仕組みです。

Firepowerの Threat Intelligence Director(TID) は STIXフォーマットを取り扱うことができます。
以下の STIXフォーマットで記述された脅威情報をオープンソース脅威情報サイトである Hail A TAXIIより、TAXIIを使って情報を受信してみました。
オープンソース脅威情報サイト: http://hailataxii.com/

・Hailataxii MalwareDomainListをダウンロードして設定
以下の宛先にTIDが必要とする情報をPOST

https:// <YOURFMCIP> /api/fmc_tid/v1/domain/ <doimain_uuid:> /tid/source
{
  "startHour": 2,
  "name": "Sample TAXII Feed",
  "description": "Sample TAXII Feed",
  "feedType": "stix",
  "feedContent": "stix",
  "delivery": "taxii",
  "uri": "http://hailataxii.com/taxii-discovery-service",
  "username": "guest",
  "passwd": "guest",
  "refresh": 1440,
  "version": "1.0.0",
  "downloadOn": true,
  "subscribedCollections": [
    {
      "collectionPollIntervalInMinutes": 0,
      "collectionName": "guest.MalwareDomainList_Hostlist",
      "collectionDescription": "guest.MalwareDomainList_Hostlist",
      "collectionProtocolBinding": "urn:taxii.mitre.org:protocol:https:1.0",
      "collectionAddress": "http://hailataxii.com:80/taxii-data",
      "collectionMessageBinding": "[urn:taxii.mitre.org:message:xml:1.1]",
      "type": "taxii_collections"
    }
  ],
  "params": {
    "selfSignedServerCertificate": "false",
    "hostnameVerifier": "allow_all"
  },
  "property": {
    "ttl": 90,
    "publish": true,
    "action": "monitor"
  }
}

成功時のレスポンス例

{
    "property": {
        "expirationTime": 1521776899,
        "action": "monitor",
        "ttl": 90,
        "publish": true,
        "whitelist": false
    },
    "username": "guest",
    "uri": "http://hailataxii.com/taxii-discovery-service",
    "params": {
        "selfSignedServerCertificate": "false",
        "hostnameVerifier": "allow_all"
    },
    "lastRun": 0,
    "nextRun": 0,
    "subscribedCollections": [
        {
            "type": "taxii_collections",
            "collectionPollIntervalInMinutes": 0,
            "collectionDescription": "guest.MalwareDomainList_Hostlist",
            "collectionName": "guest.MalwareDomainList_Hostlist",
            "collectionProtocolBinding": "urn:taxii.mitre.org:protocol:https:1.0",
            "collectionAddress": "http://hailataxii.com:80/taxii-data",
            "collectionMessageBinding": "[urn:taxii.mitre.org:message:xml:1.1]"
        }
    ],
    "downloadOn": true,
    "runNow": false,
    "feedStatus": "new",
    "consumedIndicators": 0,
    "feedType": "stix",
    "feedContent": "stix",
    "delivery": "taxii",
    "refresh": 1440,
    "totalIndicators": 0,
    "discardedIndicators": 0,
    "totalDiscardedIndicators": 0,
    "totalObservables": 0,
    "invalidObservables": 0,
    "consumedObservables": 0,
    "consumedUnsupportedObservables": 0,
    "totalUnsupportedObservables": 0,
    "totalInvalidObservables": 0,
    "links": {
        "self": "https://<YOURFMCIP>/api/fmc_tid/v1/domain/e276abec-e0f2-11e3-8169-6d9ed49b625f/tid/source/ZDUyNDFjNTI1NTJhODkzNjRmZjk4NjdhOTZhOWEyMTg4OGY5MDMzNw"
    },
    "description": "Sample TAXII Feed",
    "name": "Sample TAXII Feed",
    "id": "ZDUyNDFjNTI1NTJhODkzNjRmZjk4NjdhOTZhOWEyMTg4OGY5MDMzNw",
    "type": "source"

FMC TIDの GUIを見るとさっそくフィードを受け取りはじめました。

スクリーンショット 2017-12-23 13.26.49.png

どんな脅威情報なのか中身を見ていきます。

スクリーンショット 2017-12-23 13.28.44.png

INDICATION PATTERNに記述される情報は、脅威に関する情報です。
Firepower TIDはネットワーク上で検知できる情報を使って脅威を発見するため、まずはドメイン・IPv4情報は役立ちそうです。

参考までに受信した STIXファイルの中身を記述しておきます。
STIXファイルの中は単に検知するための脅威情報ではなく、観測された事象など脅威に対する理解が深まる情報が入っています。

<stix:STIX_Package id="edge:Package-208085c8-a992-4ac8-bdc7-9fceab613ea2" timestamp="2017-12-23T03:48:56.998664+00:00" version="1.1.1" xmlns:TOUMarking="http://data-marking.mitre.org/extensions/MarkingStructure#Terms_Of_Use-1" xmlns:cybox="http://cybox.mitre.org/cybox-2" xmlns:cyboxCommon="http://cybox.mitre.org/common-2" xmlns:cyboxVocabs="http://cybox.mitre.org/default_vocabularies-2" xmlns:edge="http://soltra.com/" xmlns:indicator="http://stix.mitre.org/Indicator-2" xmlns:marking="http://data-marking.mitre.org/Marking-1" xmlns:opensource="http://hailataxii.com" xmlns:simpleMarking="http://data-marking.mitre.org/extensions/MarkingStructure#Simple-1" xmlns:stix="http://stix.mitre.org/stix-1" xmlns:stixCommon="http://stix.mitre.org/common-1" xmlns:stixVocabs="http://stix.mitre.org/default_vocabularies-1" xmlns:taxii="http://taxii.mitre.org/messages/taxii_xml_binding-1" xmlns:tdq="http://taxii.mitre.org/query/taxii_default_query-1" xmlns:tlpMarking="http://data-marking.mitre.org/extensions/MarkingStructure#TLP-1" xmlns:ttp="http://stix.mitre.org/TTP-1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

                <stix:STIX_Header>

                    <stix:Handling>

                        <marking:Marking>

                            <marking:Controlled_Structure>../../../../descendant-or-self::node()</marking:Controlled_Structure>

                            <marking:Marking_Structure color="WHITE" xsi:type="tlpMarking:TLPMarkingStructureType"/>

                            <marking:Marking_Structure xsi:type="TOUMarking:TermsOfUseMarkingStructureType"><TOUMarking:Terms_Of_Use>www.malwaredomainlist.com | Malware Domain List - is a non-commercial community project. Our list can be used for free by anyone. Feel free to use it. 
</TOUMarking:Terms_Of_Use>
                </marking:Marking_Structure>

                            <marking:Marking_Structure xsi:type="simpleMarking:SimpleMarkingStructureType"><simpleMarking:Statement>Unclassified (Public)</simpleMarking:Statement>
                </marking:Marking_Structure>
            </marking:Marking>
        </stix:Handling>
    </stix:STIX_Header>

                <stix:Indicators><stix:Indicator id="opensource:indicator-a1741f93-1304-497e-b255-942894b5f4ab" timestamp="2017-10-26T15:20:43.834217+00:00" version="2.1.1" xsi:type="indicator:IndicatorType"><indicator:Title>Compromised Site: : photoscape.ch/Setup.exe</indicator:Title><indicator:Type xsi:type="stixVocabs:IndicatorTypeVocab-1.1">IP Watchlist</indicator:Type><indicator:Type xsi:type="stixVocabs:IndicatorTypeVocab-1.1">Domain Watchlist</indicator:Type><indicator:Type xsi:type="stixVocabs:IndicatorTypeVocab-1.1">URL Watchlist</indicator:Type><indicator:Description>This domain photoscape.ch (31.148.219.11) located in CZ (Czech Republic), has been identified as Malious [trojan] by www.malwaredomainlist.com. For more detailed infomation about this indicator go to [CAUTION!!Read-URL-Before-Click] [http://www.malwaredomainlist.com/mdl.php?search=photoscape.ch].</indicator:Description><indicator:Observable idref="opensource:Observable-78c151c6-47bc-4e54-ac2d-a74287a5a664">
            </indicator:Observable><indicator:Indicated_TTP><stixCommon:TTP idref="opensource:ttp-e53314dd-4f0c-46e3-86a4-1490d593be70" xsi:type="ttp:TTPType"/>
            </indicator:Indicated_TTP><indicator:Producer><stixCommon:Identity id="opensource:Identity-32d1e62f-3990-4bf2-9e49-a3297bd36eac"><stixCommon:Name>www.malwaredomainlist.com</stixCommon:Name>
                </stixCommon:Identity><stixCommon:Time><cyboxCommon:Produced_Time>2017-10-26T13:48:00+00:00</cyboxCommon:Produced_Time><cyboxCommon:Received_Time>2017-10-26T15:20:43+00:00</cyboxCommon:Received_Time>
                </stixCommon:Time>
            </indicator:Producer>
        </stix:Indicator>
    </stix:Indicators>
</stix:STIX_Package>

■おまけ
脅威情報として報告された URLについて調べてみました。
まずは一般的に知られているのかVirusTotalで確認してみます。

スクリーンショット 2017-12-23 13.37.35.png

悪意があると判定されているケースが多数見受けられます。
最後は世界中ドメインに関わる脅威情報を集めている Cisco Umbrellaで調査してみます。

スクリーンショット 2017-12-23 13.46.29.png

既に Blacklistに登録されていますが、一時的に問い合わせが集中していることを見ると
何かしらキャンペーンとしてばらまかれた可能性が高いと判断できます。

7
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
3