Miami Herald의Nabbed on way to beard-growing contest, 'OxyMonster' to plead to drug charge in Miami[1]기사에따르면, Gal Vallerius는 프랑스 출신의 붉은 수염을 가진 38세 남성이다.다크 웹에서 그의 닉네임은OxyMonster로 코카인, 헤로인 등을 포함한 불법 마약 시장인 드림 마켓 (Dream Market)의 관리자로 활동하였다.
DEA ( Drug Enforcement Administration )는 Gal Vallerius를 검거하기 위해 마약을 판매하는 딜러로 부터 직접 마약을 구매하여 OxyMonster가 거래 시에 특정 비트코인 주소만 사용한다는 단서를 확보하였다.
그들은 곧 특정 비트코인 주소에서 들어오고 나가는 거래를 분석하였고, 비트코인 거래의 대부분이 Localbitcoins.com에서 Vallerius로 갔다는 것을 발견하였다.
또한, OxyMonster가 Gal Vallerius라는 여러 가지의 단서 중 하나인 온라인 상에서의 글쓰기 스타일은 Gal Vallerius의 인스타그램, 트위터 계정에서의 글쓰기 스타일과 OxyMonster의 글쓰기 스타일을 비교한 결과, “cheers”라는 단어를 사용하는 것과 빈번하게 사용하는 따옴표 및 프랑스 관련 게시물을 통해 많은 유사점을 발견하였다고 한다.
그 결과, Gal Vallerius는 텍사스의 오스틴에서 열리는 수염 대회에 참가하러 가던 도중, 2017년 8월 31일 미국 애틀란타에서 체포되었다.
[1] Miami Herald, Nabbed on way to beard-growing contest, 'OxyMonster' to plead to drug charge in Miami
전체 다크 웹 중, 한국어로 운영되는 다크 웹이 차지하는 비중은 그리 크지 않다. 하지만 불과 4년 사이에 크고 작은 한국 다크 웹 마켓들이 생겨나고, 사라지고, 이슈화되고, 실제 운영자, 구매자와 판매자가 검거된 사례가 기사화되고 있다.
토르네트워크에 접속한 한국인 사용자의 수도 2016.02.20 – 2020.02.20 사이에서 2016년의 중순 쯤 대폭 감소한 다음, 2017년 하순부터 꾸준히 증가한 사실을 확인할 수 있다. 본 포스트에서는 2016년을 기준으로 생성된 한국 다크 웹에 대한 내용을 다루고자 한다.
Tor Metrics - Users, Relay users
[1] 베리마켓
베리마켓은 한국 다크 웹 중, 아동 포르노를 제외한 모든 품목을 판매하는 것을 처음으로 시작한 블랙 마켓이다. 아래 베리마켓 규칙에 의하면, 베리마켓 내에서 활동을 하기 위해서는 반드시 등업 과정을 거쳐야하고, 거래 시에는 이메일, 카카오톡, 텔레그램 등과 같은 표면 웹에서 사용되는 프로그램이 아닌 GPG 암호화를 통한 거래 방식을 이용할 것을 당부한다.
베리마켓은 처음으로 모든 품목을 판매한 블랙 마켓이지만, 처음으로 다크 웹의 블랙 마켓에서 활동한 판매자와 구매자가 검거된 블랙 마켓이다. 현재 베리마켓은 존재하지 않고, 폐쇄된 상태이다.
베리마켓 규칙
[2] 하이코리아
하이코리아는 한국 다크 웹에서 가장 오래된 마약 판매 마켓이며 아직까지도 거래가 활성화되어 있는 마켓이다. 아래 로그인 페이지에서 로그인 계정 없이도 접근할 수 있는 게시판이 5개 정도 활성화되어 있으며, 5개의 게시판에서는 잡담과 공지에 대한 내용들을 포함하고 있다.
로그인 페이지
다음 그림은 하이코리아 회원 등급에 대한 정보이다. 보통 일반적으로 등업 신청을 하면 가장 처음에 주어지는 등급이 하이코리아 Marine 이다. 하이코리아에서는 총 8가지의 회원 등급이 존재한다. 회원 등급별 설명은 아래와 같다.
하이코리아 회원 등급 목록
회원 등급에 따라 활성화되는 게시판의 수도 다르다. 하이코리아 Marine 은 일반 정회원에 해당되는 등급이다. 대마초에 대한 후기, 재배 방법에 대한 정보를 얻을 수 있으며, 3개월 이상 활동 후에는 그림 3과 같이 SCV 마켓과 HIGH 경매 포럼에 접근할 수 있는 권한을 가진 하이코리아 Ghost 로 등업 신청을 할 수 있는 게시판이 활성화 된다.
Ghost 등업 조건
Ghost 등업 조건에서 보이는 글은 하이코리아 Marine 으로 등업 후, 활성화되는 게시판에 있는 글 중 하나이다. 다음은 대마초 재배 방식을 공유하는 대마재배 게시판이다. 실제 대마초와 같은 마약과 관련된 재배방법, 재배용품, 재배사진과 재배강좌와 같이 다양한 하위 포럼들로 이루어져 있다.
대마재배 게시판
[3] 666 LETOM
666 LETOM은 베리마켓과 같이 아동 포르노를 제외한 모든 품목을 판매하는 블랙 마켓이다. 정회원으로 등업하기 위해 진행되는 등업 신청 방식은 하이코리아의 등업 신청 방식과 유사하다. 현재 666 LETOM은 존재하지 않고, 폐쇄된 상태이다.
666 LETOM 로그인 페이지
[4] 동부전선
동부전선은 베리마켓 다음으로 가장 큰 규모의 대형 종합 마켓이다. 베리마켓은 아동 포르노를 제외한 모든 품목을 판매하였지만, 동부전선에서는 아동 포르노까지 포함한 모든 품목을 판매하였다. 회원 가입을 위해서 동부전선에서 활동하는 판매자를 통해서만 받을 수 있는 리퍼러 코드가 필요하다. 현재 동부전선은 존재하지 않고, 폐쇄된 상태이다.
동부전선 로그인 페이지
[5] 천리안
천리안은 현재 하이코리아와 같이 마약을 판매하는 마켓이다. 다른 마약 판매 사이트와는 달리, 마약 거래에 필요한 GPG의 개념과 사용법 숙지, BTC 지갑 준비에 대해 상세하게 안내하는 공지 글을 볼 수 있다.
로그인 페이지등업 신청
등업 신청 시에는 운영자가 질문하는 질문에 대한 답변을 PGP 공개키로 메세지를 암호화하여 작성해야 한다. 등업 신청에서 답변이 필요한 질문은 총 2가지이다.
등업 신청 질문
다음 문단에서는 한국 다크웹에서 마약을 거래하는 방식과 자금 추적을 피하기 위해 가상화폐를 세탁하는 방식을 다루고자 한다.
한국 다크 웹에서의 마약 거래 방식
[1] 한국 다크 웹 거래 방식
한국 다크 웹 마켓별 거래 방식 (2017)
한국 다크 웹 내에서의 구매자와 판매자의 거래 방식은 크게 두 가지, 다이렉트와 에스크로로 나뉜다. 이 중, 제 3자 (중개자)를 통해 거래하는 에스크로 방식을 도입한 마켓의 안전도가 구매자와 판매자가 바로 거래하는 다이렉트 방식보다 안전하다.
[2] 일대일 거래 방식
구매자 – 판매자 ( 딜러 ) 거래
다이렉트: 다이렉트는 중개자없이 구매자와 판매자가 직접 거래하는 방식이다. 구매자가 판매자에게 지불한 후에는 판매자가 구매자에게 던지기 방식으로 마약을 전달한다.
[3] 제 3자를 통한 거래 방식
구매자 – 중개자(운영자) – 판매자(딜러)
에스크로[1]: 에스크로는 구매자와 판매자 사이에 제3자가 중개자로서 구매 대금을 임시로 맡은 다음, 거래가 성사된 후에 중개자가 판매자에게 구매 대금을 전달하는 방식이다. 중개자가 판매자에게 구매 대금을 전달한 후에는 판매자가 구매자에게 던지기 방식으로 마약을 전달한다.
*보통 중개자가 5% 정도의 수수료를 가져간다.
*던지기: 판매자가 임의의 장소에 마약을 두고, 구매자에게 주소와 위치를 알려준 다음에 구매자가 찾아가는 방식이다. 예) xx시 xx동 XX빌라 앞, 자전거 바구니
한국 다크 웹에서의 가상화폐 세탁 방식
다크 웹에서는 비트코인, 이더리움, 모네로 등과 같은 가상화폐를 활용하여 거래한다. 물론 가상화폐가 익명성이 보장된다는 점 때문에 주로 사용하지만, 혹시 모를 상황을 위해 가상화폐 믹싱 서비스를 제공하는 사이트가 존재한다.
“한국 다크 웹에서는 어떤 가상화폐 믹싱 서비스가 있었을까?” 라는 의문을 시작으로 한국 다크 웹에서 서비스되었던 가상화폐 믹싱 서비스들을 크게 두 가지로 정리한다.
[1] 마켓 내, 회원전용 서비스
하이코리아의 운영자 Neo는 비빔밥 게시판에서 비트코인 믹싱 서비스를 회원들에게 제공하였다.
현재 하이코리아에서 비트코인 믹싱 서비스 (비빔밥)는 제공하지 않고 있다.
비트코인 믹싱 서비스를 제공할 당시, 아래 사진과 같이 제목 (“비빔밥 한 그릇”)과 PGP키를 활용하여 비트코인 믹싱을 한 다음에 받을 비트코인 지갑 주소를 작성하여 비빔밥 게시판에 등록하면 비트코인 믹싱 서비스를 신청할 수 있다.
하이코리아 비빔밥 서비스
[2] 비트코인 믹싱 전문 사이트
LAVADORA는 비트코인 믹싱 서비스를 제공하는 한국 다크 웹 사이트이다. 회원제로 운영되며, 해당 서비스에 가입한 회원들의 정보를 열람할 수 있다. 하지만 사이트의 운영 기간이 짧아 히든위키 코리아에는 기록된 데이터가 없다. 현재 LAVADORA는 존재하지 않고, 폐쇄된 상태이다.
[공유] Peerlyst - Some useful Open Source Intelligence (OSINT) tools by David Dunmore
해당 포스트는 Peerlyst - Some useful Open Source Intelligence (OSINT) tools by David Dunmore 포스트에 있는 OSINT 도구들에 대한 내용만 발췌한 포스트입니다.
Maltego
The aim ofMaltegois to analyze real world relationships between people, web pages and sites, groups,domains,network infrastructure, SocialNetworks, and indeed anything else that is discoverable on the internet. Maltego can then present these results in a variety of graphical formats.
Here’s Maltego’sUIfrom my installation (On PCLinuxOS using the rpm packaged installation file), showing the default transforms, and a couple of useful free (As in free Beer) that I’ve found to be useful.
I wrote a short series of two posts about Maltego’s free Community edition a while ago called ‘How to use Maltego’Part 1andPart 2.
Shodan
On theHome page,Shodandescribes itself as ‘Thesearch enginefor theInternetOf Things’. It not a free Open Sourceresource, rather Shodan has severalsubscription plans, which are on a monthly rolling basis, so you can subscribe for just one month to evaluate its usefulness. The main difference between them is the number ofIP addressesper month you can access.
Shodan also has anAPI, use of which is included with all the subscription options, but you have to register separately to access the API. Thedocumentationfor Shodan’sREST APIis availablehere.
NOTE: All the API methods are limited to 1 request per second. This may or may not be a limitation you can live with. Fordevelopmentpurposes it’s unlikely to be an issue, but I can see this being a bottleneck in some investigative scenarios.
Despite the overtly nerdy, techy name, there’s really nothing mysterious going on here. Simply put,GoogleDorksare just smarter / more advanced ways to search using Google for more specific results. Once you’re familiar with some of thesetechniques, you will (genuinely) wonder how you searched previously.
“Double quotes” - (“”) search specifically for the exact words inside the double quotes
Being a British Railway nerd, I searched for “Bulleid Pacific Clan Line” which returned 102 results specific to that particular locomotive which was built in the 1940s for British Railways Southern Region.
Camera:£350 This one does not give exactly the result you might expect. It does return one result for cameras under £350, but also several results for cameras that feature the number 350 in their names. Under the default ‘All’ search, search using the ‘shopping’ tab does indeed return a large number of results for cameras under £350, including someIPcameras andCCTVones as well.
To be a bit more flexible, try camera £100..£300 for cameras in that price range. Again for best results, choose the ‘shopping’ tab.
You can use AND. OR to combine results. e.g. camera AND film to exclude digital cameras.
To search socialmedia, use the @operatore.g. @Facebook or @twitter
intext:MarsRover Finds web pages that include ‘Mars Rover’ in their text (57.5 million results when I tried this one).
Site:autotrader.co.uk Limits the search to the specified site
for more, there’s the link above, but there are many more, just search for ‘Google Dorks’ and be amazed!
While not Dorks per se, Google have a number of other usefulresources, including images and maps. One I have found to be very handy isGoogle Correlate
Here’s a simple example, I used the term ‘Diet and Exercise’
CheckUserNames
This is potentially a very useful site, the aim is to see whether a givenusernameis available on any of more than 160social networkingsites. The homepage isCheck User Names, If you enter a username, the site will highlight which sites have the name available. It’s a handy way of seeing whether a given username is registered on social media. The site also has a link to their new siteknowem.com, which claims to check more than 500 social media sites I tried some of my social media usernames, and the site (CheckUserNames) did correctly identify the sites where the names have been registered.
The FOCA
FingerprintingOrganizationswith Collected Archives to expand on the (possibly devised to fit the tool’s functionality) acronym.
The main purpose of this tool is to findmetadataand other hidden data contained in a variety of documents and some image files and to show relationships, for example, that some documents may have been produced by the same person or team.
FOCAis aWindowsapplication that requires an instance ofSQLServerto be available for it to store its search results, which may produce a large volume of data.
The FOCA is open source, released under theGNUPublic License (GPL), and is available fordownloadfromthis GitHub page.
Eleven Paths, who are the authors, also have aFOCA market pagewhere you can download several plugins to expand on FOCA’s functionality.
While thinking about what useful information can be found in metadata, another very useful tool is
Metagoofil,
written by Christian Martorella ofEdgeSecurity, here’sMetagoofil’s pageIt’s written forLinuxand can be downloaded as a .tar.gz file from Google Code Archivehere. It’s not been updated since Feb 10 2013, but that may not matter, provided thefunctionalityis correct. Metagoofil ins included in Buscador below, where it can be found in Software → Domains, which opens a small box titled ‘Domains: Choose tool, which containsradiobuttons to choose a tool:
Clicking OK opens another small message with an input field for aURLto search. enter a URL, and
Metagoofil will go off and do its thing. Returning its findings in the form of anhtmlpage in its own folder.
Is anautomatedOSINT tool that gathers freely available information from more than 100 public sources, the type of information thatSpiderfootcan gather includes IP addresses, Email addresses, names, and quite a lot more. It can present the information that it finds in a variery of graphical formats
Spiderfoot is available for Linux,BSD, Solaris and Windows. The Windows version is a freestandingexecutable(.exe file) that appears to be portable as the website says that it comes pre-packaged will all dependencies.
If you don’t want to compile Spiderfoot for Linux, it is also available packaged for Docker.
If you useKali Linux, you’ll know that Spiderfoot is not included in the default Kalidistribution, but it can be installedHere's a link to a tutorial blog post. Note that some browsers may flag this as a site that has been reported as containing harmful software. That’s because it contains links to download Spiderfoot.
This is aLinux distroloaded with OSINT tools, available as aVirtual Machine(VM)image for bothVirtualBoxand VMWare. It is developed and maintained by David Westcott and Michael Bazzell, and hosed onGoogle DriveThe link for the download, and a list of included OSINTapplicationsare available fromIntelTechniqueson theirBuscador page, which also has a helpful list of installation notes, and some helpful notes on using the image in avirtualmachine.
This may be the subject of a future post (or short series of posts) in some detail – watch this space!
Although this is intended primarily as aPenetrationtester’stoolkit, it aims to be the pentester’s ‘SwissArmyKnife),Kalidoes contain several tools of interest to the OSINT investigator, includingMetagoofilandThe Harvester, which is a tool used to gather email accounts and sub-domains from publicly available sources, and a number of other tools. If you've not considered Kali for its OSINT tools, do have a kook, there’s a good amount of video tutorials on YouTube,this link will find them.
There are also a similarly good number of video tutorials covering The Harvester on YouTube,this link will find them
Search Engines
And let’s not overlook the obvious start point for most OSINT (or indeed any otherintelligencegathering) – Search engines, and Google in particular, have become soembeddedin our consciousness that they may not register as the valuable tools that they undoubtedly are. If you doubt that, imagine trying to find a supplier of cheap watches inChinaor Japan (If you’re in Europe or the USA)withoutinternet accessand a search engine.)
Some (like Google,Bingand Yahoo) willtrackyour searches, others, primarilyDuckDuckGomake a point of NOTtrackingyour searches.
Some of the others, Ask for example have changed their underlying technology. Ask, at one time ‘Ask Jeeves) was for a while effectively a re brandedYahoosearch (as is Swagbucks search currently), now however, Ask.com appears to be it’s own thing, and any association with another search engine is not readily apparent. Tracking these changes of ownership might be an interesting OSINT exercise.
Please feel free to do this exercise, and post your results in the comments section under this post.
Some old (And I thought long defunct) search engines are still going likeDog Pile, which used to search several other engines ad return aggregated results.This sitelists several other search engines, and a number of other resources that are useful for OSINT investigations.
Have I Been Pwned
This is a very useful site, just enter anemail addressand the site will tell you whether the email address has beenpwned(found among others in one or more breaches) try it here:Have I Been Pwned.
If you need to check a file for knownviruses, thenVirusTotal is the place to go, here’s theirupload pagewhere you can upload a suspect file for checking. Virus Total also have a number of APIscriptsallowingdevelopersto use the Virus Checking functionality within their applications.
A variety of languages are supported, as are Maltego, in the form of a couple of transforms.
They also have andappforAndroidin the Play Store,desktopapplications for Windows and Mac, but not specifically for Linux, although the Mac application (which uses Qt) can be compiled for you own distribution andbrowser extensionsforChrome,FirefoxandInternet Explorer, but apparently not for Edge yet.
Forums (Fora?)
There’s any number of forums dedicated to most interests (including some that are illegal in most jurisdictions). The best way to find forums, if they’re relevant to your research, is probably to use a search engine (I preferDuckDuckGoas it doesn’t track your activity).
It’s worth using mire than one search, using slightly different terms, as they can sometimes give differing results.
Blogs
there are a number of sites than claim to help you find blogs on any subject, but the one that works for me isThe Blog Search Engine which along with blogs on the chosen subject, will also return YouTube videos and other related sites.
An event is a single occurrence within an environment, usually involving an attempted state change. An event usually includes a notion of time, the occurrence, and any details the explicitly pertain to the event or environment that may help explain or understand the event's causes or effects.
위 내용을 빠르게 요약하면 이벤트는 일반적으로 시도된 상태 변화와 관련된 환경에서의 single occurrence (e.g. 단일 발생, 적절한 사례) 이다.
여기서 로그 소스는 두 가지의 일반적인 카테고리로 나눌 수 있다고 한다.
푸시 기반과 풀 기반으로 나뉘는데, 푸시 기반은 장치나 애플리케이션이 로컬 디스크나 네트워크를 통해 메시지를 전송하는 것을 말한다.(e.g. syslog, SNMP, 윈도우 이벤트 로그 - 프로토콜, 전송 메커니즘, 저장, 검색 기능 제공)
그리고 풀 기반은 애플리케이션이 소스에서 로그 메시지를 가져오는 것을 말한다. (클라이언트 - 서버 모델에 의존) 이 방식으로 동작하는 대 다수의 시스템은 로그 데이터를 전용 포맷 형태로 저장한다고 한다.
로그 저장 포맷의 종류는 아래와 같이 크게 3 가지의 종류로 나뉜다.
텍스트 기반 로그 파일
플랫 텍스트 파일 (일반적인 유형: syslog 포맷)
인덱스 플랫 텍스트 파일 (OSSEC라는 로그 보관 유틸리티가 사용하는 전략)
가장 강력한 유틸리티: 아파치 루씬 코어 Apache Lucene Core
루씬은 전체 텍스트를 로깅하고 로그 검색과 분석 유틸리티를 통합하는 인덱스를 생성할 수 있는 자바 기반의 프레임워크를 말한다.
ex. 엘라스틱서치가 루씬 기반이다. 루씬이 제공하는 기능의 대부분 지원하며, 엘라스틱서치를 사용할 시에는 루씬을 사용할때의 불편함을 간소화할 수 있는 장점이 있다. [티몬의 개발이야기 - 인용])
바이너리 파일
일반적인 바이너리 로그 파일 예제: 마이크로소프트 IIS 로그와 윈도우 이벤트 로그
압축 파일
tar, zip 포맷은 오랫동안 사용되어 왔으며, PKZip 포맷 압축 파일은 윈도우 공통 포맷이다.
zgrep과 zcat 도구를 이용하면 grep과 cat으로 압축하지 않은 파일에서 읽는 것처럼 압축 파일에서 데이터를 읽고 검색할 수 있다.
다음으로, 로그를 얻을 수 있는 방법은 무엇이 있을까? 아니면 로그를 얻을 수 있는 자원은 무엇일까? 우리는 아래와 같은 자원에서 우리는 다양한 로그를 얻을 수 있다.
유닉스와 윈도우 시스템
라우터
스위치
방화벽
무선 AP
가상 사설망
안티바이러스 시스템
프린터
그럼 이렇게 다양한 로그를 수집 후, 보관할때 따라야하는 정책들은 무엇이 있을까? 책에서는 다양한 정책들을 보여주었지만, 초반에는 PCI DSS 만을 다루었다. PCI DSS는 Payment Card Industry Data Security Standard 이며, 여기서 다루는 내용은 컴플라이언스 요구사항 평가, 조직의 위험 상태 검토, 다양한 로그 소스의 생성 로그 크기 확인, 가능한 저장장치 선택 검토를 다룬다.
[3] 전송 메커니즘 / 솔루션
대표적으로 로그 전송에서 사용되는 메커니즘 5 가지는 아래와 같다.
syslog UCP/TCP
암호화된 syslog
HTTP 상에서 SDAP
SNMP
FTPS나 SCP와 같은 일반 파일 전송
그리고 로그와 관련된 솔루션은 어떤 것들이 있을까, 이런 솔루션들을 통칭하는 단어는 무엇일까라는 생각이 들었는데, 이 또한 책에 아래와 같이 정리되어 있었다.
다크웹/딥웹 관련 리서치를 꾸준히 하면서 이와 관련된 데이터 유출 사고에 대해서만 중점적으로 다루는 내용의 포스트가 없었습니다. 해당 포스트에서는 그와 관련된 내용들을 자세히 정리하고, 참고한 자료들에 대한 링크들도 아래에 남겨두었습니다. 또한, 새롭게 일어난 사고에 대해서도 꾸준히 업데이트할 예정입니다.
다크웹 딥웹 관련 데이터 유출 사건 정리
References
620 million accounts stolen from 16 hacked websites now for sale on dark web, seller boasts
오늘은 오픈 API에 공개되어 있는 예금자보호 금융상품 조회 서비스 API 와 우체국금융 보험상품정보 조회 서비스 API를 활용해서 시중에서 거래되고 있는 보험 상품 정보들을 스크래핑하는 스크립트를 간단히 소개해드리고자 합니다. 인슈어테크 관련 해커톤에 나갔다가 수상은 못했지만, 여러모로 쓸모있을 거 같아 블로그를 통해 공유합니다.
예금자보호 금융상품 조회 서비스 API 와 우체국금융 보험상품정보 조회 서비스 API를 활용해서 시중 보험 상품 정보 스크래핑
사용한 오픈 API 정보
#-*- coding:utf-8 -*
import requests
import json
#update datas from openapi
def getPostProduct():
keyword = ""
productList = []
resultList = []
postProductJson = {"getProductList": ""}
key = "<<set key>>"
url = "http://apis.data.go.kr/1721301/KpostInsuranceProductView/insuranceGoods?serviceKey="+ key +"&GOOD_ABNM=" + keyword
response = requests.get(url)
jsonData = json.loads(response.content.decode(encoding='utf-8'))
groupData = jsonData["response"]["body"]["items"]["item"]
for data in groupData:
resultList.append({"prtName":data["GOOD_ABNM"], "item":data})
postProductJson["getProductList"] = resultList
with open("postProduct.json", 'w', encoding='utf8') as outfile:
json.dump(postProductJson, outfile, ensure_ascii=False)
def getNotCompany():
key = "<<set key>>"
rows = "10000"
type = "json"
pTypeList = ["금융투자", "은행", "저축은행"]
notCompanyList = ["우리종합금융㈜"]
for pType in pTypeList:
url = "http://apis.data.go.kr/B190017/service/GetInsuredProductService/getCompanyList?serviceKey=" + key + "&numOfRows=" + rows + "&resultType=" + type + "®nNm=" + pType
response = requests.get(url)
jsonData = json.loads(response.content.decode(encoding='utf-8'))
groupData = jsonData['getCompanyList']['item']
for data in groupData:
company = data['fncIstNm']
notCompanyList.append(company)
return notCompanyList
def getCompany():
key = "<<set key>>"
rows = "10000"
type = "json"
url = "http://apis.data.go.kr/B190017/service/GetInsuredProductService/getCompanyList?serviceKey=" + key + "&numOfRows=" + rows + "&resultType=" + type
response = requests.get(url)
jsonData = json.loads(response.content.decode(encoding='utf-8'))
groupData = jsonData['getCompanyList']['item']
notCompanyList = getNotCompany()
companyList = []
for data in groupData:
company = data['fncIstNm']
check = str(company in notCompanyList)
if check == "False":
companyList.append(company)
return companyList
def getProduct(company):
key = "<<set key>>"
rows = "10000"
type = "json"
url = "http://apis.data.go.kr/B190017/service/GetInsuredProductService/getProductList?serviceKey=" + key + "&numOfRows=" + rows + "&resultType=" + type + "&fncIstNm=" + company
productList = []
response = requests.get(url)
jsonData = json.loads(response.content.decode(encoding='utf-8'))
groupData = jsonData['getProductList']['item']
for data in groupData:
if data['prdSalDscnDt'] == "":
productList.append(data['prdNm'])
return productList
if __name__ == "__main__":
getPostProduct()
productJson = {"getProductList": ""}
resultList = []
companyList = getCompany()
for company in companyList:
productList = getProduct(company)
result = {"company": company, "item": productList}
resultList.append(result)
productJson["getProductList"] = resultList
with open("product.json", 'w', encoding='utf8') as outfile:
json.dump(productJson, outfile, ensure_ascii=False)