گرفتن شل در یک لینوکس از طریق گراب:
grub page> press e grub page> linux /boot/vmlinuz-4.8.0 root=/dev/sda7 ro init=/bin/bash grub page> ctrl+x bash mount -rw -o remounr /
گرفتن شل در یک لینوکس از طریق گراب:
grub page> press e grub page> linux /boot/vmlinuz-4.8.0 root=/dev/sda7 ro init=/bin/bash grub page> ctrl+x bash mount -rw -o remounr /
دستور زیر یک عبارت را به رمزنگاری تبدیل میکند
$ echo "salam" | base64 output: c2FsYW0K $ base64 -d <<< c2FsYW0K output: salam
ماژول pam_access.so در لینوکس وجود دارد ولی به کرنل اضافه نشده است و باید برای ایجاد محدودیت آن را به کرنل اضافه نماییم
برای اینکار:
$ vim /etc/security/access.conf: #add role: + : root : ALL $ vi /etc/pam.d/password-auth account <tab> required <tab> pam-access.so
نکته: میتوان از syntax فایل login موجود در مسیر pam.d موجود در مسیر etc استفاده کرد
Zones: The firewalld daemon manages groups of rules using entities called “zones”
predefined zones:
drop: The lowest level of trust. All incoming connections are dropped without reply and only outgoing connections are possible.
block: Similar to the above, but instead of simply dropping connections, incoming requests are rejected with an icmp-host-prohibited or icmp6-adm-prohibited message.
public: Represents public, untrusted networks. You don’t trust other computers but may allow selected incoming connections on a case-by-case basis.
external: External networks in the event that you are using the firewall as your gateway. It is configured for NAT masquerading so that your internal network remains private but reachable.
internal: The other side of the external zone, used for the internal portion of a gateway. The computers are fairly trustworthy and some additional services are available.
dmz: Used for computers located in a DMZ (isolated computers that will not have access to the rest of your network). Only certain incoming connections are allowed.
work: Used for work machines. Trust most of the computers in the network. A few more services might be allowed.
home: A home environment. It generally implies that you trust most of the other computers and that a few more services will be accepted.
trusted: Trust all of the machines in the network. The most open of the available options and should be used sparingly.
Rule Permanence: In firewalld, rules can be designated as either permanent or immediate. Most firewall-cmd operations can take the "--permanent" flag
Install and Enable Your Firewall to Start at Boot
$ sudoyum install firewalld Install $ sudo systemctl enable firewalld $ sudo reboot
verify the service is running and reachable by typing:
$ sudo firewall-cmd --state output: running
Current Firewall Rules( which zone is currently selected as the default)
firewall-cmd --get-default-zone output: publicPrint currently active zones
Print currently active zones
firewall-cmd --get-active-zones output: privateDNS interfaces: eth1 publicweb interfaces: eth0
list of the available zone
$ sudo firewall-cmd --get-zones output: block dmz drop external home internal public trusted work
see the specific configuration associated with a zone
$ sudo firewall-cmd --zone=home --list-all output : home interfaces: sources: services: dhcpv6-client ipp-client mdns samba-client ssh ports: masquerade: no forward-ports: icmp-blocks: rich rules:
see the specific configuration associated with all zone
sudo firewall-cmd --list-all-zones
list of the available services
firewall-cmd --get-services output RH-Satellite-6 amanda-client amanda-k5-client bacula bacula-client bitcoin bitcoin-rpc bitcoin-testnet bitcoin-testnet-rpc ceph ceph-mon cfengine condor-collector ctdb dhcp dhcpv6 dhcpv6-client dns docker-registry dropbox-lansync elasticsearch freeipa-ldap freeipa-ldaps freeipa-replication freeipa-trust ftp ganglia-client ganglia-master high-availability http https imap imaps ipp ipp-client ipsec iscsi-target kadmin kerberos kibana klogin kpasswd kshell ldap ldaps libvirt libvirt-tls managesieve mdns mosh mountd ms-wbt mssql mysql nfs nrpe ntp openvpn ovirt-imageio ovirt-storageconsole ovirt-vmconsole pmcd pmproxy pmwebapi pmwebapis pop3 pop3s postgresql privoxy proxy-dhcp ptp pulseaudio puppetmaster quassel radius rpc-bind rsh rsyncd samba samba-client sane sip sips smtp smtp-submission smtps snmp snmptrap spideroak-lansync squid ssh synergy syslog syslog-tls telnet tftp tftp-client tinc tor-socks transmission-client vdsm vnc-server wbem-https xmpp-bosh xmpp-client xmpp-local xmpp-server
list services
sudo firewall-cmd --zone=public --list-all sudo firewall-cmd --zone=public --list-services
List of ports
sudo firewall-cmd --zone=public --list-ports
Changing the Zone of an Interface
sudo firewall-cmd --zone=home --change-interface=eth0 output success
Adjusting the Default Zone
sudo firewall-cmd --set-default-zone=home
allow http/https traffic in our “public” zone
sudo firewall-cmd --zone=public --add-service=http sudo firewall-cmd --zone=public --add-service=http --permanent sudo firewall-cmd --zone=public --add-service=https sudo firewall-cmd --zone=public --permanent --add-service=https
Opening a Port for your Zones
sudo firewall-cmd --zone=public --add-port=5000/tcp sudo firewall-cmd --zone=public --add-port=4990-4999/udp sudo firewall-cmd --zone=public --permanent --add-port=5000/tcp sudo firewall-cmd --zone=public --permanent --add-port=4990-4999/udp sudo firewall-cmd --zone=public --permanent --list-ports
change interface over zones
sudo firewall-cmd --zone=public --change-interface=eth0
tcpdump -i eth0 #Capture Packets from Specific Interface
tcpdump -i any #Capture all packets in any interface
tcpdump -c 5 -i eth0 #Capture Only N Number of Packets
tcpdump -A -i eth0 #Print Captured Packets in ASCII
tcpdump -D #Display Available Interfaces
tcpdump -XX -i eth0 #Display Captured Packets in HEX and
tcpdump -w 0001.pcap -i eth0 #Capture and Save Packets in a File
tcpdump -r 0001.pcap #Read Captured Packets File
tcpdump -n #show IP address replace name (disable name resolution)
tcpdump -nn #show port address replace name (disable port resolution with -nn
tcpdump tcp #Capture only TCP Packets.
tcpdump port 22 #Capture Packet from Specific Port
tcpdump port 80 #capture packets related to a web (HTTP) service
tcpdump -i eth0 src 192.168.0.2 #Capture Packets from source IP
tcpdump -i eth0 dst 50.116.66.139 #Capture Packets from destination IP
tcpdump --number #show acket numbers in output
tcpdump -t #omit timestamp info from tcpdump outpu
tcpdump -v #show detailed output
tcpdump icmp #capture ICMP packets only
tcpdump host 54.204.39.132 #only packets related to a specific host
tcpdump -i any -c5 -nn \
src 192.168.122.98 and port 80 #filter packets from source IP address 192.168.122.98 and service HTTP only
tcpdump -i any -c5 -nn "port 80 \
and (src 192.168.122.98 \
or src 54.204.39.132)" #filtering packets for HTTP service only (port 80) and source IP addresses 192.168.122.98 or 54.204.39.132
cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
vim /etc/selinux/config
SELINUX=enforcing
سوکتهای فعلی سرور که به هیچ فایلی از هارد وصل نشده است - پردازههای موجود در رم که ممکن است ویروس باشند
lsof +L1
برای راه اندازی وی پی ان از طریق terminal در لینوکس به روش زیر عمل مینماییم
modprobe nf_conntrack_pptp # add pptp module to kernel
pppd call linuxconfig # stablished Tunnel
route add default dev ppp0 #route all traffic to Tunnel
اسکریپت شده دستورات بالا:
نکته: یکی از dependency های اسکریپت بالا URL
دستورات بالا با دوفایل ارتباط دارد که این فایلها وقتی بخواهیم بدون اسکریپت بالا پیکربندی کنیم به صورت زیر عمل خواهیم کرد.
vim /etc/ppp/peers/linuxconfig
vim /etc/ppp/pap-secret
--------------e---- 970107.txt
$ echo salam >> /tmp/970107.txt salam
$ sudo chattr +i /tmp/970107.txt----i---------e---- 970107.txt$ echo salam2 >> /tmp/970107.txt
bash: /tmp/970107.txt: Operation not permitted$ sudo rm -rf /tmp/970107.txt
rm: cannot remove '/tmp/970107.txt': Operation not permitted$ sudo mv /tmp/970107.txt ~
mv: cannot move '/tmp/970107.txt' to '/home/behrooz/970107.txt': Operation not permitted$ sudo chattr -i /tmp/970107.txt
--------------e---- /tmp/970107.txt
برنامه ufw فایروالی است که به حالت سرویس به اجرا درآمده و بسته های ورودی و خروجی را فیلتر مینماید.
استفاده از آی پی ورژن6
# sudo vim /etc/default/ufw
IPV6=yes
فعال سازی/غیرفعال سازی
# sudo ufw enable/disable
بررسی وضعیت موجود
# sudo ufw status
# sudo ufw status numbered
بررسی وضعیت موجود(جزییات بیشتر)
# sudo ufw status verbose
نمایش رولها
# sudo ufw status numberedNumbered Output: Status: active To Action From -- ------ ---- [1] 22 ALLOW IN 15.15.15.0/24 [2] 80 ALLOW IN Anywhere
حذف رولهای موجود(شماره [2 ])
# sudo ufw delete 2
# sudo ufw delete allow http
# sudo ufw delete allow 80
# sudo ufw default deny incoming
# sudo ufw default allow outgoing
بازگشت به حالت اولیه-فایروال غیرفعال گشته و قوانین حذف خواهند شد (نکته پالیسیهای پیشفرض ورودی و خروجی تغییر نخواهد کرد)
# sudo ufw reset
باز بودن تمام دسترسی از یک آدرس آی پی خاص
# sudo ufw allow from 15.15.15.51باز شدن دسترسی از هاست 15.15.15.51 به پورت 22 سرور
# sudo ufw allow from 15.15.15.51 to any port 22باز کردن یک پورت
# sudo ufw allow PORT
# sudo ufw allow PORT/tcp
باز کردن یک بازه پورت
باز شدن پورت ssh
# sudo ufw allow ssh
# sudo ufw allow 22
بسته شدن پورت پروتکل اف تی پی
# sudo ufw allow ftp
ریست تمام رولها به حالت اولیه:
# sudo ufw reset