Rework Dirs
This commit is contained in:
40
Security & Networking/CronJob/CronJob.md
Normal file
40
Security & Networking/CronJob/CronJob.md
Normal file
@@ -0,0 +1,40 @@
|
||||
```txt
|
||||
.---------------- minute (0 - 59)
|
||||
| .------------- hour (0 - 23)
|
||||
| | .---------- day of month (1 - 31)
|
||||
| | | .------- month (1 - 12) OR jan,feb,mar,apr ...
|
||||
| | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
|
||||
| | | | |
|
||||
* * * * * user-name command to be executed
|
||||
```
|
||||
Here are some examples to illustrate different cron job schedules:
|
||||
|
||||
### Example 1: Run at 12:55 every day
|
||||
```
|
||||
55 12 * * * root hi
|
||||
```
|
||||
This command runs `hi` as the `root` user every day at 12:55.
|
||||
|
||||
### Example 2: Run every minute
|
||||
```
|
||||
*/1 * * * * root hi
|
||||
```
|
||||
This command runs `hi` as the `root` user every minute.
|
||||
|
||||
### Example 3: Run every 2 minutes
|
||||
```
|
||||
*/2 * * * * root hi
|
||||
```
|
||||
This command runs `hi` as the `root` user every 2 minutes.
|
||||
|
||||
### Example 4: Run at specific minutes
|
||||
```
|
||||
10,20,30 10 * * * root hi
|
||||
```
|
||||
This command runs `hi` as the `root` user at 10:10, 10:20, and 10:30.
|
||||
|
||||
### Example 5: Run after every reboot
|
||||
```
|
||||
@reboot root hi
|
||||
```
|
||||
This command runs `hi` as the `root` user after system reboot.
|
||||
75
Security & Networking/FileSharing/smb.md
Normal file
75
Security & Networking/FileSharing/smb.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# آموزش نصب و تنظیم SMB در لینوکس
|
||||
یا Server Message Block پروتکلی جهت به اشتراک گذاری فایل ها، چاپگرها و پورتهای سریال است. از این پروتکل می توان بر روی پروتکل TCP/IP یا بر روی دیگر پروتکل های شبکه استفاده کرد.
|
||||
|
||||
**این آموزش فقط روی Ubuntu 22.04 LTS آزمایش و تست شده است. اگر می خواهید روی Ubuntu Server از این آموزش استفاده کنید. به جای gedit از nano یا vim استفاده کنید**
|
||||
|
||||
## مرحله اول: نصب Samba
|
||||
پروتکل SMB در لینوکس با Samba پیاده سازی می شود برای نصب Samba از دستور زیر استفاده کنید
|
||||
|
||||
sudo apt update
|
||||
sudo apt install samba
|
||||
|
||||
**اختیاری:** با استفاده از دستور زیر از نصب بودن Samba اطمینان پیدا کنید
|
||||
|
||||
whereis samba
|
||||
|
||||
## مرحله دوم: تنظیمات Samba
|
||||
نخست یک پوشه با نام و مسیر دلخواه که می خواهید آن را به اشتراک بگذارید بسازید یا انتخاب کنید. من با دستور زیر پوشه ای برای این پروژه می سازم
|
||||
|
||||
mkdir /home/mahdiyar/smbshare
|
||||
|
||||
**نکته: به جای Mahdiyar ُ نام کاربری خود را جایگزین کنید**
|
||||
فایل تنظیمات **Samba** را با دستور زیر باز کنید
|
||||
|
||||
sudo gedit /etc/samba/smb.conf
|
||||
|
||||
۵ خط کد زیر را به آخر فایل اضافه کنید
|
||||
|
||||
[sambashare]
|
||||
comment = Mahdiyar XPS File Share
|
||||
path = /home/mahdiyar/smbshare
|
||||
read only = no
|
||||
browsable = yes
|
||||
|
||||
**نکته مهم:** به جای `/home/mahdiyar/smbshare` آدرس پوشه ای را که برای اشتراک گذاری انتخاب کردید قرار دهید
|
||||
|
||||
**نکته مهم:** به جای `Mahdiyar XPS File Share` متنی دلخواه که پوشه شما را توصیف می کند قرار دهید
|
||||
|
||||
با دستور زیر Smaba را Restart کرده و اطمینان پیدا کنید که به درستی کار می کند
|
||||
|
||||
|
||||
sudo service smbd restart
|
||||
sudo service smbd status
|
||||
|
||||
|
||||
اگر از فایروال استفاده می کنید با دستور زیر Samba را به فایروال اضافه کنید
|
||||
|
||||
sudo ufw allow samba
|
||||
|
||||
|
||||
با دستور زیر رمز عبوری برای Samba مشخص کنید
|
||||
|
||||
sudo smbpasswd -a username
|
||||
|
||||
**نکته مهم: username حتما باید نام کاربری شما در Ubuntu باشد**
|
||||
|
||||
## مرحله سوم: استفاده از SMB
|
||||
حالا که سرور را آماده کردیم نوبت به استفاده از فولدری که به اشتراک گذاشتیم رسیده است
|
||||
|
||||
با دستور زیر در لینوکس IP سرور خود را مشخص می کنیم
|
||||
|
||||
ifconfig
|
||||
|
||||
### استفاده در ویندوز
|
||||
|
||||
|
||||
با وارد کردن `//linuxserverip/sambashare` در منوی جستجو ویندوز می توان به پوشه که به اشتراک گذاشتیم دسترسی پیدا کرد
|
||||
|
||||
### استفاده در سیستم عامل های دیگر
|
||||
|
||||
[استفاده از SMB در اندروید](https://www.techrepublic.com/article/how-to-connect-to-an-smb-share-from-your-android-device/)
|
||||
|
||||
[استفاده از SMB در iPhone/iPad](https://osxdaily.com/2019/11/04/how-connect-smb-share-iphone-ipad-files-app/)
|
||||
|
||||
[استفاده از SMB در لینوکس (گنوم)](https://www.zdnet.com/article/how-to-connect-to-a-network-share-from-the-gnome-desktop/#:~:text=At%20the%20bottom%20of%20the,the%20computer%20hosting%20the%20sare%29.)
|
||||
|
||||
52
Security & Networking/Iptables/iptables.md
Normal file
52
Security & Networking/Iptables/iptables.md
Normal file
@@ -0,0 +1,52 @@
|
||||
## First Whitelist Port and Block Ports at the End
|
||||
|
||||
|
||||
|
||||
```bash
|
||||
iptables -A/-I/-D INPUT/OUTPUT/FORWARD -i/-o interface -s/-d address -p tcp/udp/icmp --sport/--dport 80 -j ACCEPT/REJECT/DROP/LOG/MASQUARATE
|
||||
```
|
||||
|
||||
- `-A`: Append
|
||||
- `-I`: Insert
|
||||
- `-D`: Delete
|
||||
- `-i`: Input interface
|
||||
- `-o`: Output interface
|
||||
- `-s`: Source
|
||||
- `-d`: Destination
|
||||
- `-p`: Protocol
|
||||
- `--sport`: Source port
|
||||
- `--dport`: Destination port
|
||||
- `-j`: Action
|
||||
- `ACCEPT`: Accept the packet
|
||||
- `REJECT`: Reject the packet with an appropriate ICMP message
|
||||
- `DROP`: Silently discard the packet
|
||||
- `LOG`: Log the packet
|
||||
- `MASQUERADE`: Source NAT
|
||||
|
||||
### Examples:
|
||||
|
||||
- `iptables -nvL`: Print Iptables Rules
|
||||
- `iptables -P INPUT DROP`: Drop All Incoming Packets
|
||||
- `iptables -P OUTPUT DROP`: Drop All Outgoing Packets
|
||||
- `iptables -A INPUT -p tcp --dport 22 -j ACCEPT`: Accept Incoming Traffic to Port 22 with TCP Protocol
|
||||
- `iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT`: Accept Outgoing Traffic from Port 22 with TCP Protocol
|
||||
- `iptables -A INPUT -p tcp -s 192.168.1.100 -j DROP`: Drop All Packets Incoming With TCP Protocol From 192.168.1.100
|
||||
- `iptables -A INPUT -p tcp --dport 443 -j ACCEPT`: Accept Incoming Traffic to Port 443 (HTTPS) with TCP Protocol
|
||||
- `iptables -A INPUT -p tcp -m multiport --dport 22,443,80,3306 -j ACCEPT`: Accept Incoming Traffic to Multiple Ports: 22 (SSH), 80 (HTTP), 3306 (Database), 443 (HTTPS) with TCP Protocol
|
||||
- `iptables -A INPUT -p tcp -m multiport --dport 22,443,80,3306 -d 192.168.10.0/24 -j ACCEPT`: Accept Incoming Traffic to Multiple Ports: 22 (SSH), 80 (HTTP), 3306 (Database), 443 (HTTPS) with TCP Protocol to Destination 192.168.10.0
|
||||
- `iptables -A INPUT -p tcp --dport 80 -m limit --limit 100/minute --limit-burst 200 -j ACCEPT`: Allow incoming TCP traffic on port 80 with rate limiting
|
||||
- `iptables -t NAT -A PREROUTING -i ens33 -p tcp --dport 80 -j REDIRECT --to-port 443`: Redirect traffic from port 80 to port 443 using NAT
|
||||
|
||||
### Saving rules for permanent:
|
||||
|
||||
To save the rules for permanent usage, you can install the `iptables-persistent` package:
|
||||
|
||||
```bash
|
||||
apt install iptables-persistent
|
||||
```
|
||||
|
||||
Then, save the rules to the appropriate file:
|
||||
|
||||
```bash
|
||||
iptables-save > /etc/iptables/rule.v4
|
||||
```
|
||||
144
Security & Networking/nmap/Nmap.md
Normal file
144
Security & Networking/nmap/Nmap.md
Normal file
@@ -0,0 +1,144 @@
|
||||
### How to Install Nmap and Use Nmap for Scanning
|
||||
|
||||
1. **Update your system:**
|
||||
```bash
|
||||
sudo apt-get update
|
||||
```
|
||||
|
||||
2. **Install Nmap:**
|
||||
```bash
|
||||
sudo apt install nmap
|
||||
```
|
||||
|
||||
3. **Scan a single IP address:**
|
||||
```bash
|
||||
nmap [your_IP]
|
||||
```
|
||||
|
||||
4. **Scan multiple IP addresses:**
|
||||
```bash
|
||||
nmap [your_IP1,your_IP2]
|
||||
```
|
||||
|
||||
5. **Scan a range of IP addresses:**
|
||||
```bash
|
||||
nmap [your_IP1-your_IP100]
|
||||
```
|
||||
|
||||
6. **Scan targets from a text file:**
|
||||
```bash
|
||||
nmap -iL filename.txt
|
||||
```
|
||||
|
||||
7. **Check for live systems:**
|
||||
```bash
|
||||
nmap -sn [your_IP]
|
||||
```
|
||||
|
||||
8. **Ping sweep:**
|
||||
```bash
|
||||
nmap -sP [your_IP]
|
||||
```
|
||||
|
||||
9. **If ICMP is blocked:**
|
||||
```bash
|
||||
nmap -PN [your_IP]
|
||||
```
|
||||
|
||||
10. **Scan specific port:**
|
||||
```bash
|
||||
nmap -p [your_port] [your_IP]
|
||||
```
|
||||
If ICMP is blocked:
|
||||
```bash
|
||||
nmap -PN [your_IP] -p [your_port]
|
||||
```
|
||||
|
||||
11. **Scan multiple ports:**
|
||||
```bash
|
||||
nmap -p [port1,port2,port3-port6] [your_IP]
|
||||
```
|
||||
|
||||
12. **Specify protocol:**
|
||||
```bash
|
||||
nmap -p http,https,ftp [your_IP]
|
||||
```
|
||||
|
||||
13. **Scan TCP ports:**
|
||||
```bash
|
||||
nmap -p T:[port,port2] [your_IP]
|
||||
```
|
||||
|
||||
14. **Get more information:**
|
||||
```bash
|
||||
nmap -p [your_port] -sV [your_IP]
|
||||
```
|
||||
|
||||
15. **Detect operating system:**
|
||||
```bash
|
||||
nmap -O [your_IP] -p [your_port]
|
||||
```
|
||||
|
||||
16. **Fast scan (top 100 ports):**
|
||||
```bash
|
||||
nmap -F [your_IP]
|
||||
```
|
||||
|
||||
17. **Aggressive scan:**
|
||||
```bash
|
||||
nmap -A [your_IP] -p [your_port]
|
||||
```
|
||||
|
||||
18. **Whois lookup:**
|
||||
```bash
|
||||
nmap -p [your_port] --script whois-ip [your_IP_or_domain]
|
||||
```
|
||||
|
||||
19. **IP geolocation:**
|
||||
```bash
|
||||
nmap -p [your_port] --script ip-geolocation-* [IP]
|
||||
```
|
||||
|
||||
20. **Detect Web Application Firewall (WAF):**
|
||||
```bash
|
||||
nmap -p [your_port] --script http-waf-detect [your_domain]
|
||||
```
|
||||
|
||||
21. **Save results to a text file:**
|
||||
```bash
|
||||
nmap -Pn -p [your_port] [your_IP] -oN your_filename.txt
|
||||
```
|
||||
|
||||
22. **Save results to an XML file:**
|
||||
```bash
|
||||
nmap -Pn -p [your_port] [your_IP] -oX filename.xml
|
||||
```
|
||||
|
||||
23. **Save results to a grepable file:**
|
||||
```bash
|
||||
nmap -Pn -p [your_port] [your_IP] -oG filename.gnmap
|
||||
```
|
||||
|
||||
24. **Save results to all formats:**
|
||||
```bash
|
||||
nmap -Pn -p [your_port] [your_IP] -oA filename
|
||||
```
|
||||
|
||||
25. **Scan top ports:**
|
||||
```bash
|
||||
nmap --top-ports [number] [your_domain]
|
||||
```
|
||||
|
||||
26. **Scan top ports and show open ones:**
|
||||
```bash
|
||||
nmap --top-ports [number] [your_domain] --open
|
||||
```
|
||||
|
||||
27. **Check for open ports using different scan types:**
|
||||
```bash
|
||||
nmap -sT [your_IP] # TCP Scan
|
||||
nmap -sS [your_IP] # SYN Scan
|
||||
nmap -sX [your_IP] # XMAS Scan
|
||||
nmap -sF [your_IP] # FIN Scan
|
||||
nmap -sN [your_IP] # Null Scan
|
||||
```
|
||||
Reference in New Issue
Block a user