
recon-ng와 Maltego에서 영감을 받은 주관적인 조직 중심의 OSINT 발자국 수집
공지
이 프로젝트는 부분적으로만 완료되었으며, 아래 블로그 게시물에 설명된 많은 기능을 아직 구현하지 못했습니다: https://penafieljlm.com/2017/07/14/inquisitor/.
Inquisitor는 오픈소스 인텔리전스(OSINT) 소스를 활용하여 회사 및 조직에 대한 정보를 수집하는 간단한 도구입니다. Maltego와 recon-ng의 작동 방식에서 크게 영감을 받았으며, 이 도구는 해당 도구들의 일부 기능을 재구현하면서 에셋 유형 위에 의견 기반 의미론(opinion-based semantics) 계층을 추가하여 사용하기 쉬운 워크플로를 만듭니다.
Inquisitor의 주요 기능은 다음과 같습니다:
Inquisitor의 전체 개념은 대상 조직에 대해 이미 알려진 정보를 기반으로 오픈 소스에서 정보를 추출하는 아이디어에 기반합니다. Inquisitor의 맥락에서 이를 "트랜스폼(transforms)"이라고 합니다. 또한 whois 및 인터넷 레지스트리와 같은 오픈 소스에서 검색 가능한 메타데이터를 기반으로 알려진 에셋에서 관련 정보를 즉시 검색할 수도 있습니다.
자세한 개념은 이 블로그 문서에서 설명합니다: https://penafieljlm.com/2017/07/14/inquisitor/
Inquisitor를 설치하려면 리포지토리를 클론하고, 해당 디렉토리로 이동한 후 설치 스크립트를 실행하기만 하면 됩니다.``` pip install Cython click git clone [email protected]:penafieljlm/inquisitor.git cd inquisitor python setup.py install
## 사용법
Inquisitor는 `scan`, `status`, `classify`, `dump`, `visualize`의 다섯 가지 기본 명령어를 제공합니다.```
usage: inq [-h] {scan,status,classify,dump,visualize} ...
optional arguments:
-h, --help show this help message and exit
command:
{scan,status,classify,dump,visualize}
The action to perform.
scan Search OSINT sources for intelligence based on known
assets belonging to the target.
status Prints out the current status of the specified
intelligence database.
classify Classifies an existing asset as either belonging or
not belonging to the target. Adds a new asset with the
specified classification if none is present.
dump Dumps the contents of the database into a JSON file
visualize Create a D3.js visualization based on the contents of
the specified intelligence database.
스캔 모드에서 이 도구는 인텔리전스 데이터베이스(Intelligence Database)에 있는 모든 자산에 대해 사용 가능한 모든 transforms를 실행합니다. 아래에 표시된 다양한 OSINT 소스에 대한 API 키를 생성하고 스크립트에 제공해야 합니다. 그렇지 않으면 해당 소스를 사용하는 transforms가 건너뛰어집니다. 또한, 먼저 classify 명령어를 사용하여 알려진 소유 대상 자산으로 인텔리전스 데이터베이스를 시드(seed)해야 합니다. 데이터베이스에 소유한 자산이 없으면 변환할 대상이 없기 때문입니다.```
usage: inq scan [-h] [--google-dev-key GOOGLE_DEV_KEY]
[--google-cse-id GOOGLE_CSE_ID]
[--google-limit GOOGLE_LIMIT]
[--shodan-api-key SHODAN_API_KEY]
[--shodan-limit SHODAN_LIMIT]
DATABASE
positional arguments: DATABASE The path to the intelligence database to use. If specified file does not exist, a new one will be created.
optional arguments: -h, --help show this help message and exit --google-dev-key GOOGLE_DEV_KEY Specifies the developer key to use to query Google Custom Search. Visit the Google APIs Console (http://code.google.com/apis/console) to get an API key. If notspecified, the script will simply skip asset transforms that involve Google Search. --google-cse-id GOOGLE_CSE_ID Specifies the custom search engine to query. Visit the Google Custom Search Console (https://cse.google.com/cse/all) to create your own Google Custom Search Engine. If not specified, the script will simply skip asset transforms that involve Google Search. --google-limit GOOGLE_LIMIT The number of pages to limit Google Search to. This is to avoid exhausting your daily quota. --shodan-api-key SHODAN_API_KEY Specifies the API key to use to query Shodan. Log into your Shodan account (https://www.shodan.io/) and look at the top right corner of the page in order to view your API key. If not specified, the script will simply skip asset transforms that involve Shodan. --shodan-limit SHODAN_LIMIT The number of pages to limit Shodan Search to. This is to avoid exhausting your daily quota.
### 상태
상태 모드에서는 도구가 스캔 데이터베이스의 상태에 대한 간략한 요약을 출력합니다.```
usage: inq status [-h] [-s] DATABASE
positional arguments:
DATABASE The path to the intelligence database to use. If specified
file does not exist, a new one will be created.
optional arguments:
-h, --help show this help message and exit
-s, --strong Indicates if the status will be based on the strong ownership
classification.
분류 모드에서는 인텔리전스 데이터베이스에 수동으로 자산을 추가하고 이미 존재하는 자산을 재분류할 수 있습니다. 이 명령을 사용하여 알려진 소유 대상 자산으로 인텔리전스 데이터베이스를 시드해야 합니다.``` usage: inq classify [-h] [-ar REGISTRANT [REGISTRANT ...]] [-ur REGISTRANT [REGISTRANT ...]] [-rr REGISTRANT [REGISTRANT ...]] [-ab BLOCK [BLOCK ...]] [-ub BLOCK [BLOCK ...]] [-rb BLOCK [BLOCK ...]] [-ah HOST [HOST ...]] [-uh HOST [HOST ...]] [-rh HOST [HOST ...]] [-ae EMAIL [EMAIL ...]] [-ue EMAIL [EMAIL ...]] [-re EMAIL [EMAIL ...]] [-al LINKEDIN [LINKEDIN ...]] [-ul LINKEDIN [LINKEDIN ...]] [-rl LINKEDIN [LINKEDIN ...]] DATABASE
positional arguments: DATABASE The path to the intelligence database to use. If specified file does not exist, a new one will be created.
optional arguments: -h, --help show this help message and exit -ar REGISTRANT [REGISTRANT ...], --accept-registrant REGISTRANT [REGISTRANT ...] Specifies a registrant to classify as accepted. -ur REGISTRANT [REGISTRANT ...], --unmark-registrant REGISTRANT [REGISTRANT ...] Specifies a registrant to classify as unmarked. -rr REGISTRANT [REGISTRANT ...], --reject-registrant REGISTRANT [REGISTRANT ...] Specifies a registrant to classify as rejected. -ab BLOCK [BLOCK ...], --accept-block BLOCK [BLOCK ...] Specifies a block to classify as accepted. -ub BLOCK [BLOCK ...], --unmark-block BLOCK [BLOCK ...] Specifies a block to classify as unmarked. -rb BLOCK [BLOCK ...], --reject-block BLOCK [BLOCK ...] Specifies a block to classify as rejected. -ah HOST [HOST ...], --accept-host HOST [HOST ...] Specifies a host to classify as accepted. -uh HOST [HOST ...], --unmark-host HOST [HOST ...] Specifies a host to classify as unmarked. -rh HOST [HOST ...], --reject-host HOST [HOST ...] Specifies a host to classify as rejected. -ae EMAIL [EMAIL ...], --accept-email EMAIL [EMAIL ...] Specifies a email to classify as accepted. -ue EMAIL [EMAIL ...], --unmark-email EMAIL [EMAIL ...] Specifies a email to classify as unmarked. -re EMAIL [EMAIL ...], --reject-email EMAIL [EMAIL ...] Specifies a email to classify as rejected. -al LINKEDIN [LINKEDIN ...], --accept-linkedin LINKEDIN [LINKEDIN ...] Specifies a LinkedIn Account to classify as accepted. -ul LINKEDIN [LINKEDIN ...], --unmark-linkedin LINKEDIN [LINKEDIN ...] Specifies a LinkedIn Account to classify as unmarked. -rl LINKEDIN [LINKEDIN ...], --reject-linkedin LINKEDIN [LINKEDIN ...] Specifies a LinkedIn Account to classify as rejected.
### Dump
덤프 모드에서는 인텔리전스 데이터베이스의 내용을 사람이 읽을 수 있는 JSON 파일로 덤프할 수 있습니다.```
usage: inq dump [-h] [-j FILE] [-a] DATABASE
positional arguments:
DATABASE The path to the intelligence database to use. If
specified file does not exist, a new one will be
created.
optional arguments:
-h, --help show this help message and exit
-j FILE, --json FILE The path to dump the JSON file to. Overwrites existing
files.
-a, --all Include rejected assets in dump.
시각화 모드에서는 Intelligence Repository의 계층적 시각화를 획득할 수 있습니다.``` usage: inq visualize [-h] [-l] DATABASE
positional arguments: DATABASE The path to the intelligence database to use. If specified file does not exist, a new one will be created.
optional arguments: -h, --help show this help message and exit -l, --last Simply open the last visualization generated instead of creating a new one.
## Workflow
이제 Inquisitor의 기본 기능을 알게 되었으니, *실제로* 사용하는 방법을 배울 때입니다. Inquisitor는 다음과 같은 단계를 염두에 두고 작성되었습니다:
### Seeding
이 단계에서는 Intelligence Database에 아직 아무것도 저장되어 있지 않습니다. 어딘가에서 시작해야 하므로, 귀하의 대상 조직에 속한다고 알고 있는 자산으로 데이터베이스를 시드(seed)하십시오. 이 작업은 `classify` 명령을 사용하여 수행할 수 있습니다.
### Scanning
이제 데이터베이스에 대상 조직에 속하는 것으로 알려진 자산이 있습니다. 그런 다음 스캐닝을 진행할 수 있습니다. 이 작업은 `scan` 명령을 사용하여 수행할 수 있습니다.
Intelligence Database에서 `scan` 명령을 호출하면, Inquisitor는 `accepted`로 분류된 자산의 `transform` 메서드를 실행합니다. 스캐닝이 완료되면, 잠재적으로 대상 조직에 속할 수 있는 더 많은 자산이 생성됩니다.
새로운 자산이 생성되지 않은 경우, Intelligence Database에 새로운 정보로 시드(seed)하거나, 간단히 Reporting 단계로 진행하여 프로세스를 마무리할 수 있습니다.
### Classifying
Inquisitor가 자동으로 자산 분류를 수행하지만, 실제로 대상 조직에 속하는 일부 자산을 놓칠 수도 있습니다.
이런 경우, 데이터베이스 내용을 확인하고 수동으로 자산을 분류해야 합니다. 일반적으로 **Registrant** 자산에 주의를 기울여야 합니다. 이 자산 유형은 소유권을 자동으로 확인할 방법이 없기 때문입니다. 또한 대부분의 다른 자산 유형은 Registrant 자산의 소유권 분류에 의존하여 대상 조직에 속하는지 여부를 결정하므로, Registrant 자산에 주의를 기울이는 것이 가장 좋습니다. 게다가 처음부터 Registrant 자산이 많지 않으므로 이를 선별하는 것이 그렇게 어렵지 않을 것입니다.
### Reporting
`visualize` 명령이나 `dump` 명령을 사용하여 대상 조직에 속하는 자산의 시각화를 생성할 수 있습니다.
## Demo
다음 링크에서 도구가 실행되는 비디오 데모를 확인할 수 있습니다: https://drive.google.com/open?id=0B_O70BVu38TRclo5dWRBWkdTTWc
무료 화면 녹화 프로그램이 최대 10분까지만 녹화할 수 있어서 scan 명령의 전체 실행을 완전히 녹화하지는 못했습니다.
## Development
Inquisitor 프로젝트는 다음과 같은 형식으로 구성되어 있습니다:```
.
|-- README.md
|-- inquisitor
| |-- __init__.py
| |-- assets
| | |-- __init__.py
| | |-- block.py
| | |-- email.py
| | |-- host.py
| | |-- linkedin.py
| | `-- registrant.py
| |-- extractors
| | |-- __init__.py
| | `-- emails.py
| `-- sources
| |-- __init__.py
| |-- google_search.py
| `-- shodan_search.py
|-- inq
|-- report
| `-- index.html
|-- setup.py
`-- tests
|-- __init__.py
`-- test_inq.py
assets, extractors, sources라는 세 가지 주요 모듈이 있습니다. 메인 스크립트는 inq입니다.
개발자로서 시스템에 새로운 유형의 자산을 추가하는 데 가장 관심이 있을 것이므로 개발자 가이드는 주로 그 점에 초점을 맞출 것입니다.
실제로 자산 클래스를 구현하기 전에 먼저 Intelligence Database와 상호 작용하는 방법을 이해해야 합니다. 자산 클래스에서 관련 자산을 파생할 때 이 데이터베이스와 상호 작용할 것이기 때문입니다.
Intelligence Database의 소스 코드는 inquisitor/__init__.py 파일에 저장되어 있습니다. Intelligence Database의 논리적 래퍼의 실제 이름은 IntelligenceRepository입니다.
새 자산을 Intelligence Database에 추가하는 것은 inq 스크립트의 scan 모듈의 책임이므로 자산 클래스에서 IntelligenceRepository.get_asset_string 함수만 호출하면 됩니다. 이 함수는 주로 자산 인스턴스를 생성하거나 데이터베이스에 존재하는 경우 검색하는 데 사용합니다. 이 함수는 자산 클래스의 related 및 transform 함수에서 자산을 반환할 때 중요합니다. 새 자산 객체를 생성하는 것은 일부가 초기화 중에 네트워크 리소스를 사용하기 때문에 비용이 많이 들기 때문입니다.```
Function
IntelligenceRepository.get_asset_string(asset_type, identifier, create=False, store=False)
Description
Retrieves the primary key and asset object for the asset with the provided
type and identifier.
Parameters
asset_type: class, required
The type of the asset to retrieve from the Intelligence Database. You
will actually have to pass the class object of the asset type you want
to retrieve.
identifier: any, required
The identifier of the asset to retrieve. Consider the identifier as the
unique attribute of an asset object. As for which attribute is to be
used to identify an asset, it depends on the contents of the OBJECT_ID
variable in the asset module.
create: bool, optional, default=False
When no matching asset object is found, a new one will be created and
returned if this parameter is set to True. The new asset will not
necessarily be stored in the Intelligence Database unless specified
using the "store" parameter. However, I suggest you do not do this as
adding assets to the Intelligence Database is the responsibility of
another module.
store: bool, optional, default=False
When a new asset is created when none is found, the new one will be
stored in the Intelligence Database. As said previously, I suggest that
you do not do this as adding assets to the Intelligence Database is the
responsibility of another module.
Returns
A two-element tuple where the first element is the database primary key of
the element returned, and the second element is the deserialized asset
object retrieved from the database.
None if the asset was not found.
If the asset was not found and the create flag was set to True, the primary
key member of the tuple will be set to None.
### 자산
새로운 자산 유형을 생성하려면 `inquisitor/assets` 디렉토리 안에 새 파일을 만들고 다음 스켈레톤 코드를 붙여넣으세요:```python
import inquisitor.assets
class ASSET_NAMEValidateException(Exception):
pass
def canonicalize(ASSET_IDENTIFIER):
return ASSET_IDENTIFIER
def main_classify_args(parser):
parser.add_argument(
'-aASSET_NAME_LETTER', '--accept-ASSET_NAME',
metavar='ASSET_NAME',
type=canonicalize,
nargs='+',
help='Specifies a ASSET_NAME to classify as accepted.',
dest='ASSET_NAMEs_accepted',
default=list(),
)
parser.add_argument(
'-uASSET_NAME_LETTER', '--unmark-ASSET_NAME',
metavar='ASSET_NAME',
type=canonicalize,
nargs='+',
help='Specifies a ASSET_NAME to classify as unmarked.',
dest='ASSET_NAMEs_unmarked',
default=list(),
)
parser.add_argument(
'-rASSET_NAME_LETTER', '--reject-ASSET_NAME',
metavar='ASSET_NAME',
type=canonicalize,
nargs='+',
help='Specifies a ASSET_NAME to classify as rejected.',
dest='ASSET_NAME_rejected',
default=list(),
)
def main_classify_canonicalize(args):
accepted = set(args.ASSET_NAMEs_accepted)
unmarked = set(args.ASSET_NAMEs_unmarked)
rejected = set(args.ASSET_NAME_rejected)
redundant = set.intersection(accepted, unmarked, rejected)
if redundant:
raise ValueError(
('Conflicting classifications for ASSET_NAMEs '
': {}').format(list(redundant))
)
accepted = set([canonicalize(a) for a in accepted])
unmarked = set([canonicalize(a) for a in unmarked])
rejected = set([canonicalize(a) for a in rejected])
return (accepted, unmarked, rejected)
class ASSET_NAME(inquisitor.assets.Asset):
def __init__(self, ASSET_IDENTIFIER, owned=None):
super(self.__class__, self).__init__(owned=owned)
self.ASSET_IDENTIFIER = canonicalize(ASSET_IDENTIFIER)
# TODO: Perform other initialization actions here
def __eq__(self, other):
if not isinstance(other, self.__class__):
return False
return self.ASSET_IDENTIFIER == other.ASSET_IDENTIFIER
def related(self, repo):
# Prepare the results
results = set()
# TODO: Create related assets here based on the attributes of this asset
# Return the results
return results
def transform(self, repo, sources):
# Prepare the results
assets = set()
# Google Transforms
if sources.get('google'):
subassets = self.cache_transform_get('google', repo)
if not subassets:
# Acquire API
google = sources['google']
# TODO: Perform Google queries here and the results to 'subassets'
# Cache The Transform
self.cache_transform_store('google', subassets)
assets.update(subassets)
# Shodan Transforms
if sources.get('shodan'):
subassets = self.cache_transform_get('shodan', repo)
if not subassets:
# Acquire API
shodan = sources['shodan']
# TODO: Perform Google queries here and the results to 'subassets'
# Cache The Transform
self.cache_transform_store('shodan', subassets)
assets.update(subassets)
# Return the results
return assets
def is_owned(self, repo):
if self.owned:
return True
# TODO: Automatically determine ownership based on repo contents
return False
def parent_asset(self, repo):
# TODO: Return parent asset based on repo contents
return None
REPOSITORY = 'ASSET_REPOSITORY'
ASSET_CLASS = ASSET_NAME
OBJECT_ID = 'ASSET_IDENTIFIER'
이제 다음 문자열을 적절한 값으로 바꾸세요.
ASSET_NAME : 에셋의 적절한 이름 (예: Registrant, Host 등)ASSET_IDENTIFIER : 에셋의 식별자 속성 이름ASSET_NAME_LETTER : 에셋 이름의 첫 글자 (소문자)ASSET_REPOSITORY : 에셋 이름의 복수형 (소문자)마지막으로, inquisitor/__init__.py에서 에셋을 ASSET_MODULES 목록에 등록하세요. 해당 파일에서 새 에셋을 가져오는 것을 잊지 마세요.
축하합니다! 이제 새로운 작동하는 에셋 유형을 갖게 되었습니다!
하지만 에셋이 다른 에셋 유형과 연관되도록 하려면 다음 메서드를 구현해야 합니다:``` Function
related
Description
Returns the set of assets directly related to the asset in question (i.e.
those that can be derived without querying a search engine).
When creating asset objects, make sure you use the
IntelligenceRepository.get_asset_string method instead of instatiating a
new one your self so the asset can be returned from the repository if it
exists.
Set the create flag to True when calling the method in question in order
to return a new object when one isn't found.
Set the store flag to False as appending assets is the job of another
module.
Parameters
repo: IntelligenceRepository
The Intelligence Repository that is being used in the current context.
Returns
Set of assets directly related to the asset in question.
[No input text provided.]```
Function
transform
Description
Returns the set of assets potentially related to the asset in question
(i.e. those that can be derived by querying a search engine).
You may access search engine objects through the provided sources
parameter.
Each search engine object has a transform method which automatically
creates asset objects for you. You just need to provide it the repository
and your query string, and then append the objects it returns to the set
of assets to be returned by your asset's transform method.
Parameters
repo: IntelligenceRepository
The Intelligence Repository that is being used in the current context.
sources: dict
The list of search engine objects that are available for use.
Returns
Set of assets potentially related to the asset in question.
Please provide the Markdown content to translate.``` Function
is_owned
Description
Determines if there is high confidence that this asset does indeed belong
to the target. Usually checks for any "strong" classification tag first by
looking at the contents of the "owned" variable, before performing
automatic evaluation.
Automatic evaluation depends on what type of asset you're writing. For
example, for a Host asset, the secondary sources of determining ownership
would include looking if its registrant is owned by the target, if it's
parent domain is owned by the target. etc.
Parameters
repo: IntelligenceRepository
The Intelligence Repository that is being used in the current context.
Returns
True it is determined with high confidence that this asset does indeed
belong to the target.
Function
parent_asset
Description
Returns the asset object that is considered the parent of this asset
object.
Parameters
repo: IntelligenceRepository
Returns
The asset object that this asset falls under (e.g. a Block is under a
Registrant, a Host is under a Block, a Host is under another Host, an Email
is under a Host, etc. This is primarily used for visualization.
```
위 방법들을 구현한 후, 에셋 소스 코드 하단에 `REPOSITORY`, `ASSET_CLASS`, `OBJECT_ID` 변수를 설정해야 합니다.
## 연락처 및 참고 사항
스캔 모드는 관련 검색 엔진의 할당량 문제로 인해 완전히 테스트되지 않았습니다. 또한 이 프로젝트는 일주일 동안의 해커톤 챌린지의 일환으로 급하게 만들어졌기 때문에 여기저기 많은 문제가 있을 수 있습니다. 버그를 발견하거나 질문이 있으면 이슈 티켓을 생성하거나 [email protected]으로 연락해 주세요.
## 면책 조항
이 작업은 Maltego 및 recon-ng 오픈 소스 인텔리전스 도구에서 구현된 접근 방식을 기반으로 합니다. 저는 이러한 접근 방식에 이미 일반적으로 알려진 아이디어(예: whois는 도메인 소유자가 누구인지 알려주고, 서브도메인은 상위 도메인을 소유한 동일한 조직이 소유한다는 점(도메인 이름 무차별 대입 공격에서 암시됨), 조직은 자신이 소유한 도메인 이름에 대해 권위를 가짐 등) 또는 제가 취미 생활의 일환으로 개인 시간에 창안한 독창적인 아이디어(예: 수용 가능성 등급, 다양한 변환, 분류 상속 등)를 추가로 보완했습니다.
이 작업의 어떤 구성 요소도 과거에 제가 고용주를 위해 수행한 작업에서 파생되지 않았습니다. 개념 증명을 포함한 전체 프로젝트는 처음부터 작성되었으며 정보 보안 커뮤니티의 아이디어로 보강되었습니다.