use strict;
use warnings;
my $last_name = 1;
my $last_cidr = 1;
my $last_id = 1;
my @content; # json을 저장할 배열 생성
my $count = 0;
for (my $i = 0; $i < 500; $i++) { # 네트워크 대역 500개 생성
if($i < 255) { # 이중for문 구현 귀찮아서 if문으로 대체
$content[$count] = "{'id': $last_id,'group': 'Net_500','name': 'TEST_net_$last_name','description': 'test network ','cidr': '192.10.$last_cidr.0/24','domain_id': 0}";
} else { # 255개 넘어가면 오류로 입력안됨, 마지막에 1 플러스되므로 2씩 줄임.
$last_cidr -= 2;
$last_name -= 2;
$content[$count] = "{'id': $last_id,'group': 'Net_500','name': 'TEST_net_2_$last_name','description': 'test network ','cidr': '192.20.$last_cidr.0/24','domain_id': 0}";
}
$last_id++;
$last_cidr++;
$last_name++;
$count++;
};
# 배열을 한 문자열로 합치기
my $total_con = join ", ", @content;
# 모든 홀따옴표를 쌍따옴표로 변경(curl 입력시 안 끊기게)
$total_con =~ s/'/"/g;
# curl 명령어 작성
my @cmd = ("curl -S -X PUT -u admin:password12! -k -H 'Content-Type: application/json' -H 'Version: 15.0' -H 'Accept: application/json' --data-binary '[$total_con]' 'https://콘솔아이피주소/api/config/network_hierarchy/staged_networks'");
# 혹시 몰라 결과물 텍스트로 저장
open (FH, ">network-hierachy.txt") || die ("Can't open file");
print FH @cmd;
#print "Success save!\n";
# 명령어 실행
system(@cmd);
큐레이더 팀에서 올려준 파이썬 api 사용하려다가 구문 오류로 헤매서 펄 스크립트로 뚝딱 만드니 잘 되네요.
역시 필요하면 직접 만드는게 빠릅니다.
큐레이더랑 펄은 뗄려고 해도 뗄 수 없는거 같아요 ㅋㅋ
if문 안에서 1씩 자동증가하게끔 했어야하는데 나중엔 그렇게 해야죠..
'일 > IBM QRadar' 카테고리의 다른 글
[IBM QRadar] Automated offense closure (0) | 2021.10.15 |
---|---|
IBM QRadar 자동으로 오펜스 닫기(Auto closing offenses) Perl Script (0) | 2021.10.08 |
QRadar 로그 소스 (소스포트) 생성 - 펄 스크립트 (0) | 2021.10.07 |
QRadar 설치 전 주의할점 (0) | 2021.08.11 |
IBM QRadar Structure (0) | 2021.08.06 |