Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OSCD Initiative] Add response for PaloAltoNGFW #886

Merged
merged 28 commits into from
Jul 21, 2021

Conversation

Konakin
Copy link

@Konakin Konakin commented Oct 20, 2020

Add new responce for PaloAltoNGFW:

  1. Block external IP address
  2. Block internal IP address
  3. Block external domain
  4. Block internal domain
  5. Block external URL
  6. Block internal URL
  7. Block port external communication
  8. Block port internal communication
  9. Unblock blocked IP
  10. Unblock blocked domain
  11. Unblock blocked port

@yugoslavskiy
Copy link
Contributor

Hello @Konakin! Thank you for your contribution!

Could you please list the names of the Security Rules that you will use for the responder per Response Action?

@Konakin
Copy link
Author

Konakin commented Oct 25, 2020

Hello @yugoslavskiy.
I change logic response and created rules for ip, domain and users. I am going to create pull request today.

I have problems only with url and i want describe about this in next pull request.

And i think, I finish rule for port on Tuesday.

Response with rules for:
1. IP address
2. domains
3. users

This response contain security rules with default name, for use need add setting PaloAltoNGFW and the hive.
@Konakin
Copy link
Author

Konakin commented Oct 26, 2020

Hello @yugoslavskiy.

I added new commit. In this commit contains rule for ip, domain and user. Build logic:

  1. Security engineer add response in to responders folder and python script need be executable;

  2. Next step configure cortex:
    2.1. Add setting for PaloAltoNGFW (hostname, user and password);
    2.2. Add setting for the hive (url and api key).
    2.3 If you have security rule, you can add name in field with name "name_security_rule". (it's not obligatory)

  3. Run responce in the hive with type field:
    3.1. for user - "user-agent";
    3.2 for ip - "ip";
    3.3 for domain - "hostname";

  4. When start response:
    4.1 Script connect to the hive and get field with IOC.
    4.2 Script connect to PaloAltoNGFW and gets:
    4.2.1 If ip and domain - AddressObject for add IOC. And AddressGroup for add IOC List.
    4.2.2 If user - script don't work if user not in PaloAltoNGFW.

  5. Script add security rules with IOC:
    5.1 If ip and domain add AddressGroup in security rule field "destination" PaloAltoNGFW.
    5.2 If user add user list in security rule field "source_user" PaloAltoNGFW.

@Konakin
Copy link
Author

Konakin commented Oct 26, 2020

I have promblem with rule for url, because i don't known how delete ioc in url_list. When i send comand with changed url list and updated CustomUrlCategory, i get request with error text:

"panos.errors.PanDeviceXapiError: Black list internal URL -> list 'http://google.ru' is invalid. custom-url-category entry has to be type specified
Black list internal URL -> list is invalid"

but class panos.objects.CustomUrlCategory don't contains field to specify custom-url-category.
image

@Konakin
Copy link
Author

Konakin commented Oct 26, 2020

And how i wrote earlier, i will end response for port block\unblock with security rule on Tuesday, because it is looks like response for ip or domain.

Add Responder for:
1. Block internal port
2. Block external port
3. Unblock internal port
4. Unblock external port
@Konakin
Copy link
Author

Konakin commented Oct 29, 2020

hello.

i completed response for port.

i created bug report for panos.objects.CustomUrlCategory. (See #285)

@yugoslavskiy
Copy link
Contributor

Hello @Konakin!

Sorry I probably wrote a message but didn't send it.
I have a question about pre-configured Security Rules' names for each response action that you've chosen.
I assume, they could be:

  1. Block external IP address: thehive_block_external_ip_address
  2. Block internal IP address: thehive_block_internal_ip_address
  3. Block external domain: thehive_block_external_domain
  4. Block internal domain: thehive_block_internal_domain
  5. Block external URL: thehive_block_external_url
  6. Block internal URL: thehive_block_internal_url
  7. Block port external communication: thehive_block_port_external_communication
  8. Block port internal communication: thehive_block_port_internal_communication

Could you please describe how did you implement that?

@Konakin
Copy link
Author

Konakin commented Oct 29, 2020

Hello, @yugoslavskiy.

Security Rules creation logic for response:

  1. Connect to Firewall.
    Code:
    firewall.Firewall(self.hostname_PaloAltoNGFW, api_username=self.User_PaloAltoNGFW, api_password=self.Password_PaloAltoNGFW)

  2. Update rules base.
    Code:
    rulebase = panos.policies.Rulebase(); fw.add(rulebase); panos.policies.SecurityRule.refreshall(rulebase)

  3. Set paramters for security rules:
    desired_rule_params = { "name": self.name_security_rule, "description": "Block internal IP address", "type": "interzone", "action": "deny", 'destination': "Black list internal IP", 'service': "Black list external port", 'source_user': user_list }
    where:

field is:
3.1 'destination' for set AddressGroup for domain or ip address.
3.2 'service' for set ServiceGroup for port
3.3 'source_user' for add user
3.4 'name' for set name security rule
3.5 "type" for set external or internal communications
3.6 "action" for set how do if rule will be activited

  1. Add rule in Firewall:
    new_rule = panos.policies.SecurityRule(**desired_rule_params); rulebase.add(new_rule); new_rule.apply()

@Konakin
Copy link
Author

Konakin commented Oct 29, 2020

but I think if the engineer set name custom rule (not thehive_block_*) in field name_security_rule in cortex setting response, the script will overwrite setting security rules. i will fix this in next release.

@Konakin
Copy link
Author

Konakin commented Oct 29, 2020

I want to change logic create rules:

  1. If an engineer has secuirty rule and she\he want to add block ip, user, domain, port with help response cortex.
    For this need to save the settings engineer secuirty rule. (save parameters security rules what added earlier).

  2. If engineer don't have secuirty rule (she\he don't set name security rule in setting response cortex). Response cortex will add new security rule with name default. And engineer will remain change importance position.

New version response scripts for save attributes in rules
@Konakin
Copy link
Author

Konakin commented Nov 8, 2020

I changed response for custom rules. Now rules attributes will be save.

@nadouani nadouani changed the title Add responce for PaloAltoNGFW [OSCD Initiative] Add responce for PaloAltoNGFW Nov 15, 2020
@nadouani nadouani changed the title [OSCD Initiative] Add responce for PaloAltoNGFW [OSCD Initiative] Add response for PaloAltoNGFW Nov 15, 2020
@jeromeleonard jeromeleonard linked an issue Nov 18, 2020 that may be closed by this pull request
staf711 and others added 12 commits December 16, 2020 19:29
In new vesion:
1. responders in one folder.
2. responders run with case_artifact and case.
3. added prefixes to the names of the rules and the list
4. README.md

please write if you find a bug or have a suggestion for a future request.
Add main config and config for unblock ip,domain,port
1. Fix mistake with general config
2. Fix errors python code
@Konakin Konakin closed this May 17, 2021
@Konakin Konakin reopened this May 17, 2021
Konakin Maksim added 2 commits May 20, 2021 21:35
@jeromeleonard jeromeleonard merged commit 0deee22 into TheHive-Project:feature/oscd Jul 21, 2021
@jeromeleonard jeromeleonard added this to the 3.0.0 milestone Jul 21, 2021
@jeromeleonard
Copy link
Contributor

Hello,

we merged this PR. Please consider translating the readme file from RU to EN and allow everyone to access the content.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[OSCD Initiative] Develop Responder for Palo Alto NGFW
6 participants