Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Check if ufw is enabled*/
- ufw_status = Process.spawn_sync(null, {"ufw_status", ""}, null);
- if ufw_status[1].find("Status: active") != -1:
- return "enable"
- else:
- return "disable"
- /*Check if policy is incoming or outgoing*/
- if policy == "incoming":
- Process.spawn_sync(null, {"grep DEFAULT_INPUT_POLICY /etc/default/ufw", null}, out ufw_default_incoming);
- if ufw_default_incoming[1].find("ACCEPT") != -1:
- return "allow"
- elif ufw_default_incoming[1].find("DROP") != -1:
- return "deny"
- elif ufw_default_incoming[1].find("REJECT") != -1:
- return "reject"
- elif policy == "outgoing":
- Process.spawn_sync(null, {"grep DEFAULT_OUTPUT_POLICY /etc/default/ufw", null}, out ufw_default_outgoing);
- if ufw_default_outgoing[1].find("ACCEPT") != -1:
- return "allow"
- elif ufw_default_outgoing[1].find("DROP") != -1:
- return "deny"
- elif ufw_default_outgoing[1].find("REJECT") != -1:
- return "reject"
- /*Look for log level*/
- Process.spawn_sync(null, {"cat /etc/ufw/ufw.conf", null}, out ufw_cmd);
- if ufw_cmd[1].find("LOGLEVEL=full") != -1:
- return "full"
- elif ufw_cmd[1].find("LOGLEVEL=high") != -1:
- return "high"
- elif ufw_cmd[1].find("LOGLEVEL=medium") != -1:
- return "medium"
- elif ufw_cmd[1].find("LOGLEVEL=low") != -1:
- return "low"
- else:
- return "off"
Add Comment
Please, Sign In to add comment