Skip to content

Instantly share code, notes, and snippets.

@neilhwatson
Created August 13, 2014 23:52
Show Gist options
  • Save neilhwatson/76ccf4ac25e71f6e0d21 to your computer and use it in GitHub Desktop.
Save neilhwatson/76ccf4ac25e71f6e0d21 to your computer and use it in GitHub Desktop.
Jefe's module
semanage simulator:
#!/usr/bin/perl
use strict;
use warnings;
foreach my $line (<DATA>)
{
print $line. "\n";
}
__DATA__
SELinux Port Type Proto Port Number
afs_bos_port_t udp 7007
afs_client_port_t udp 7001
afs_fs_port_t tcp 2040
afs_fs_port_t udp 7000, 7005
afs_ka_port_t udp 7004
afs_pt_port_t udp 7002
afs_vl_port_t udp 7003
agentx_port_t tcp 705
agentx_port_t udp 705
amanda_port_t tcp 10080-10083
amanda_port_t udp 10080-10082
amavisd_recv_port_t tcp 10024
amavisd_send_port_t tcp 10025
amqp_port_t tcp 5671, 5672
amqp_port_t udp 5671, 5672
aol_port_t tcp 5190-5193
aol_port_t udp 5190-5193
apcupsd_port_t tcp 3551
apcupsd_port_t udp 3551
apertus_ldp_port_t tcp 539
apertus_ldp_port_t udp 539
asterisk_port_t tcp 1720
asterisk_port_t udp 2427, 2727, 4569
audit_port_t tcp 60
auth_port_t tcp 113
bgp_port_t tcp 179, 2605
bgp_port_t udp 179, 2605
boinc_port_t tcp 31416
certmaster_port_t tcp 51235
chronyd_port_t udp 323
clamd_port_t tcp 3310
clockspeed_port_t udp 4041
cluster_port_t tcp 5149, 40040, 50006-50008
cluster_port_t udp 5149, 50006-50008
cma_port_t tcp 1050
cma_port_t udp 1050
cobbler_port_t tcp 25151
commplex_port_t tcp 5000, 5001
commplex_port_t udp 5000, 5001
comsat_port_t udp 512
condor_port_t tcp 9618
condor_port_t udp 9618
ctdb_port_t tcp 4379
ctdb_port_t udp 4379
cvs_port_t tcp 2401
cvs_port_t udp 2401
cyphesis_port_t tcp 6767, 6769, 6780-6799
cyphesis_port_t udp 32771
dbskkd_port_t tcp 1178
dcc_port_t udp 6276, 6277
dccm_port_t tcp 5679
dccm_port_t udp 5679
dhcpc_port_t tcp 68, 546
dhcpc_port_t udp 68, 546
dhcpd_port_t tcp 547, 548, 647, 847, 7911
dhcpd_port_t udp 67, 547, 548, 647, 847
dict_port_t tcp 2628
distccd_port_t tcp 3632
dns_port_t tcp 53
dns_port_t udp 53
dogtag_port_t tcp 7390
dspam_port_t tcp 10026
epmap_port_t tcp 135
epmap_port_t udp 135
festival_port_t tcp 1314
fingerd_port_t tcp 79
flash_port_t tcp 843, 1935
flash_port_t udp 1935
florence_port_t tcp 1228
florence_port_t udp 1228
ftp_data_port_t tcp 20
ftp_port_t tcp 21, 990
ftp_port_t udp 990
gatekeeper_port_t tcp 1721, 7000
gatekeeper_port_t udp 1718, 1719
giftd_port_t tcp 1213
git_port_t tcp 9418
git_port_t udp 9418
glance_port_t tcp 9292
glance_port_t udp 9292
glance_registry_port_t tcp 9191
glance_registry_port_t udp 9191
gopher_port_t tcp 70
gopher_port_t udp 70
gpsd_port_t tcp 2947
hddtemp_port_t tcp 7634
hi_reserved_port_t tcp 512-1023
hi_reserved_port_t udp 512-1023
howl_port_t tcp 5335
howl_port_t udp 5353
hplip_port_t tcp 1782, 2207, 2208, 8290, 50000, 50002, 8292, 9100, 9101, 9102, 9220, 9221, 9222, 9280, 9281, 9282, 9290, 9291
http_cache_port_t tcp 3128, 8080, 8118, 8123, 10001-10010
http_cache_port_t udp 3130
http_port_t tcp 80, 81, 443, 488, 8008, 8009, 8443, 9000
i18n_input_port_t tcp 9010
imaze_port_t tcp 5323
imaze_port_t udp 5323
inetd_child_port_t tcp 1, 7, 9, 13, 19, 37, 512, 543, 544, 891, 892, 2105, 5666
inetd_child_port_t udp 1, 7, 9, 13, 19, 37, 891, 892
innd_port_t tcp 119
ionixnetmon_port_t tcp 7410
ionixnetmon_port_t udp 7410
ipmi_port_t udp 623, 664
ipp_port_t tcp 631, 8610-8614
ipp_port_t udp 631, 8610-8614
ipsecnat_port_t tcp 4500
ipsecnat_port_t udp 4500
ircd_port_t tcp 6667
isakmp_port_t udp 500
iscsi_port_t tcp 3260
isns_port_t tcp 3205
isns_port_t udp 3205
jabber_client_port_t tcp 5222, 5223
jabber_interserver_port_t tcp 5269
jabber_router_port_t tcp 5347
jacorb_port_t tcp 3528, 3529
jboss_debug_port_t tcp 8787
jboss_management_port_t tcp 4712, 4447, 7600, 9123, 9990, 9999, 18001
jboss_management_port_t udp 4712, 9123
jboss_messaging_port_t tcp 5445, 5455
kerberos_admin_port_t tcp 749
kerberos_master_port_t tcp 4444
kerberos_master_port_t udp 4444
kerberos_password_port_t tcp 464
kerberos_password_port_t udp 464
kerberos_port_t tcp 88, 750
kerberos_port_t udp 88, 750
kismet_port_t tcp 2501
kprop_port_t tcp 754
ktalkd_port_t udp 517, 518
l2tp_port_t tcp 1701
l2tp_port_t udp 1701
ldap_port_t tcp 389, 636, 3268
ldap_port_t udp 389, 636
lirc_port_t tcp 8765
lmtp_port_t tcp 24
lmtp_port_t udp 24
luci_port_t tcp 8084
mail_port_t tcp 2000, 3905
matahari_port_t tcp 49000
matahari_port_t udp 49000
memcache_port_t tcp 11211
memcache_port_t udp 11211
milter_port_t tcp 8891, 8893
mmcc_port_t tcp 5050
mmcc_port_t udp 5050
mongod_port_t tcp 27017-27019, 28017-28019
monopd_port_t tcp 1234
movaz_ssc_port_t tcp 5252
mpd_port_t tcp 6600
msnp_port_t tcp 1863
msnp_port_t udp 1863
mssql_port_t tcp 1433, 1434
mssql_port_t udp 1433, 1434
munin_port_t tcp 4949
munin_port_t udp 4949
mysqld_port_t tcp 1186, 3306, 63132-63164
mysqlmanagerd_port_t tcp 2273
nessus_port_t tcp 1241
netport_port_t tcp 3129
netport_port_t udp 3129
netsupport_port_t tcp 5404, 5405
netsupport_port_t udp 5404, 5405
nmbd_port_t udp 137, 138
nodejs_debug_port_t tcp 5858
nodejs_debug_port_t udp 5858
ntop_port_t tcp 3000, 3001
ntop_port_t udp 3000, 3001
ntp_port_t udp 123
ocsp_port_t tcp 9080
openhpid_port_t tcp 4743
openhpid_port_t udp 4743
openvpn_port_t tcp 1194
openvpn_port_t udp 1194
oracle_port_t tcp 1521, 2483, 2484
oracle_port_t udp 1521, 2483, 2484
pegasus_http_port_t tcp 5988
pegasus_https_port_t tcp 5989
pgpkeyserver_port_t tcp 11371
pgpkeyserver_port_t udp 11371
pingd_port_t tcp 9125
piranha_port_t tcp 3636
pki_ca_port_t tcp 829, 9180, 9701, 9443-9447
pki_kra_port_t tcp 10180, 10701, 10443-10446
pki_ocsp_port_t tcp 11180, 11701, 11443-11446
pki_ra_port_t tcp 12888, 12889
pki_tks_port_t tcp 13180, 13701, 13443-13446
pki_tps_port_t tcp 7888, 7889
pktcable_port_t tcp 2126, 3198
pktcable_port_t udp 2126, 3198
pop_port_t tcp 106, 109, 110, 143, 220, 993, 995, 1109
portmap_port_t tcp 111
portmap_port_t udp 111
postfix_policyd_port_t tcp 10031
postgresql_port_t tcp 5432
postgrey_port_t tcp 60000
prelude_port_t tcp 4690
prelude_port_t udp 4690
presence_port_t tcp 5298
presence_port_t udp 5298
printer_port_t tcp 515
ptal_port_t tcp 5703
pulseaudio_port_t tcp 4713
pulseaudio_port_t udp 4713
puppet_port_t tcp 8140
pxe_port_t udp 4011
pyzor_port_t udp 24441
quantum_port_t tcp 9696
radacct_port_t udp 1646, 1813
radius_port_t udp 1645, 1812
radsec_port_t tcp 2083
razor_port_t tcp 2703
repository_port_t tcp 6363
ricci_modcluster_port_t tcp 16851
ricci_modcluster_port_t udp 16851
ricci_port_t tcp 11111
ricci_port_t udp 11111
rlogind_port_t tcp 513
rndc_port_t tcp 953, 8953
router_port_t tcp 521
router_port_t udp 520, 521
rsh_port_t tcp 514
rsync_port_t tcp 873
rsync_port_t udp 873
rwho_port_t udp 513
sap_port_t tcp 9875
sap_port_t udp 9875
saphostctrl_port_t tcp 1128, 1129
sieve_port_t tcp 4190
sip_port_t tcp 5060, 5061
sip_port_t udp 5060, 5061
sixxsconfig_port_t tcp 3874
sixxsconfig_port_t udp 3874
smbd_port_t tcp 137-139, 445
smtp_port_t tcp 25, 465, 587
snmp_port_t tcp 161-162, 199, 1161
snmp_port_t udp 161-162
soundd_port_t tcp 8000, 9433, 16001
spamd_port_t tcp 783
speech_port_t tcp 8036
squid_port_t tcp 3401, 4827
squid_port_t udp 3401, 4827
ssh_port_t tcp 22
streaming_port_t tcp 1755
streaming_port_t udp 1755
svn_port_t tcp 3690
svn_port_t udp 3690
swat_port_t tcp 901
sype_port_t tcp 9911
sype_port_t udp 9911
syslogd_port_t tcp 6514
syslogd_port_t udp 514, 6514
telnetd_port_t tcp 23
tftp_port_t udp 69
tor_port_t tcp 6969, 9001, 9030, 9051
tor_socks_port_t tcp 9050
traceroute_port_t udp 64000-64010
transproxy_port_t tcp 8081
ups_port_t tcp 3493
uucpd_port_t tcp 540
varnishd_port_t tcp 6081, 6082
virt_migration_port_t tcp 49152-49216
virt_port_t tcp 16509, 16514
virt_port_t udp 16509, 16514
vnc_port_t tcp 5900-5999
wccp_port_t udp 2048
websm_port_t tcp 9090
websm_port_t udp 9090
whois_port_t tcp 43, 4321
whois_port_t udp 43, 4321
winshadow_port_t tcp 3261
winshadow_port_t udp 3261
xdmcp_port_t tcp 177
xdmcp_port_t udp 177
xen_port_t tcp 8002
xfs_port_t tcp 7100
xserver_port_t tcp 6000-6150
zabbix_agent_port_t tcp 10050
zabbix_port_t tcp 10051
zarafa_port_t tcp 236, 237
zebra_port_t tcp 2600-2604, 2606
zebra_port_t udp 2600-2604, 2606
zented_port_t tcp 1229
zented_port_t udp 1229
zope_port_t tcp 8021
Module:
#!/usr/bin/perl
use strict;
use warnings;
my $semanage = qx(./semanage -l);
if ( $semanage =~ m/http_port_t\s+tcp\s+(.*)/ )
{
my @ports = split /\s*,\s*/, $1;
$semanage = join( '", "', @ports );
$semanage = '"'. $semanage. '"';
}
print "=\@semanage_ports= { $semanage }\n";
Output:
$ ./jefe.pl
=@semanage_ports= { "80", "81", "443", "488", "8008", "8009", "8443", "9000" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment