chiwormjava 2.0.4 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/java.json +35 -27
  2. package/package.json +1 -1
  3. package/readme.md +690 -645
package/java.json CHANGED
@@ -1,39 +1,47 @@
1
1
  {
2
- "classful_classless_routing_practical": {
3
- "title": "Classful and Classless Routing Configuration using Packet Tracer",
4
- "code": "Step 1: Place devices\\nAdd in Packet Tracer:\\n2 Routers (2621XM)\\n2 Switches (2960)\\n4 PCs\\n\\nArrange as:\\nPC1 PC2 PC3 PC4\\n | | | |\\nSwitch1 Switch2\\n | |\\n Router1 ---- WAN ---- Router2\\n\\nStep 2: Add Serial Ports\\nClick Router -> Physical tab\\nTurn Power OFF\\nInsert WIC-2T module\\nTurn Power ON\\nNow Serial0/0/0 and Serial0/0/1 will be available\\n\\nStep 3: Connect cables\\nLAN:\\nPC to Switch using Copper Straight-Through\\nSwitch to Router using Copper Straight-Through\\n\\nWAN:\\nUse Serial DCE cable\\nRouter1 Serial0/0/0 to Router2 Serial0/0/0\\n\\nStep 4: Configure Router1\\nenable\\nconfigure terminal\\n\\ninterface gigabitEthernet 0/0\\nip address 192.168.1.1 255.255.255.0\\nno shutdown\\nexit\\n\\ninterface serial 0/0/0\\nip address 172.16.1.1 255.255.255.252\\nclock rate 64000\\nno shutdown\\nexit\\n\\nStep 5: Configure Router2\\nenable\\nconfigure terminal\\n\\ninterface gigabitEthernet 0/0\\nip address 10.0.0.1 255.255.255.248\\nno shutdown\\nexit\\n\\ninterface serial 0/0/0\\nip address 172.16.1.2 255.255.255.252\\nno shutdown\\nexit\\n\\nStep 6: Configure PCs\\nLeft network:\\nPC1 IP 192.168.1.2 Mask 255.255.255.0 Gateway 192.168.1.1\\nPC2 IP 192.168.1.3 Gateway 192.168.1.1\\n\\nRight network:\\nPC3 IP 10.0.0.2 Mask 255.255.255.248 Gateway 10.0.0.1\\nPC4 IP 10.0.0.3 Gateway 10.0.0.1\\n\\nStep 7: Configure Routing\\nRouter1:\\nip route 10.0.0.0 255.255.255.248 172.16.1.2\\n\\nRouter2:\\nip route 192.168.1.0 255.255.255.0 172.16.1.1\\n\\nStep 8: Verify interfaces\\nRun:\\nshow ip interface brief\\n\\nStatus should be up up\\nIf not, use no shutdown\\n\\nStep 9: Test connectivity\\nFrom PC1:\\nping 10.0.0.2\\n\\nExpected reply from destination\\n\\nStep 10: Simulation Mode\\nClick Simulation\\nReset Simulation\\nEdit Filters and select ARP and ICMP\\n\\nSend packet using Add Simple PDU from PC1 to PC3\\nClick Play or Capture/Forward\\n\\nExpected packet flow:\\nPC1 -> Switch1 -> Router1 -> Router2 -> Switch2 -> PC3\\n\\nFirst ARP then ICMP communication successful"
2
+ "nodejs_stream_server": {
3
+ "title": "Node.js File Streaming using Streams",
4
+ "code": "const http = require('http');\\nconst fs = require('fs');\\n\\nconst server = http.createServer();\\n\\nserver.on('request', (req, res) => {\\n\\tconst rstream = fs.createReadStream('./product.json', 'utf-8');\\n\\trstream.pipe(res);\\n});\\n\\nserver.on('request', (req, res) => {\\n\\n\\tconst rstream = fs.createReadStream('./product.json', 'utf-8');\\n\\n\\trstream.on('data', (chunkData) => {\\n\\t\\tres.write(chunkData);\\n\\t});\\n\\n\\trstream.on('end', () => {\\n\\t\\tres.end();\\n\\t});\\n\\n\\trstream.on('error', (err) => {\\n\\t\\tconsole.log(err);\\n\\t\\tres.writeHead(500, { 'Content-Type': 'text/plain' });\\n\\t\\tres.end('File not found');\\n\\t});\\n\\n});\\n\\nserver.listen(3000, '127.0.0.1', () => {\\n\\tconsole.log('Server is running at http://127.0.0.1:3000');\\n});"
5
5
  },
6
- "nat_configuration_practical": {
7
- "title": "NAT Configuration using Packet Tracer",
8
- "code": "Step 1: Setting Up the Topology\\nAdd devices:\\n1 Router (2911 or similar)\\n1 Switch (2960)\\n3 PCs (PC0, PC1, PC2)\\n1 Cloud or Server\\n\\nStep 2: Assign IP Addresses\\nPrivate Network:\\nPC0 IP 192.168.1.2 Mask 255.255.255.0 Gateway 192.168.1.1\\nPC1 IP 192.168.1.3 Mask 255.255.255.0 Gateway 192.168.1.1\\nPC2 IP 192.168.1.4 Mask 255.255.255.0 Gateway 192.168.1.1\\n\\nStep 3: Configure Router Interfaces\\nRouter> enable\\nRouter# configure terminal\\n\\nInterface gig0/0\\nRouter(config)# interface gig0/0\\nRouter(config-if)# ip address 192.168.1.1 255.255.255.0\\nRouter(config-if)# no shutdown\\n\\nInterface gig0/1\\nRouter(config)# interface gig0/1\\nRouter(config-if)# ip address 203.0.113.1 255.255.255.0\\nRouter(config-if)# no shutdown\\n\\nAssign IP to Cloud/Server\\nIP 203.0.113.2\\nMask 255.255.255.0\\n\\nStep 4: Configure NAT\\nDefine inside and outside interfaces\\nRouter(config)# interface gig0/0\\nRouter(config-if)# ip nat inside\\nRouter(config-if)# exit\\n\\nRouter(config)# interface gig0/1\\nRouter(config-if)# ip nat outside\\nRouter(config-if)# exit\\n\\nConfigure PAT\\nRouter(config)# access-list 1 permit 192.168.1.0 0.0.0.255\\nRouter(config)# ip nat inside source list 1 interface gig0/1 overload\\n\\nStep 5: Configure Routing\\nRouter(config)# ip route 0.0.0.0 0.0.0.0 203.0.113.2\\n\\nStep 6: Test Configuration\\nFrom PC command prompt:\\nping 203.0.113.2\\n\\nIf reply is received, NAT is working\\n\\nVerify NAT translations\\nRouter# show ip nat translations"
6
+ "nodejs_multiple_programs": {
7
+ "title": "Node.js Multiple Programs using Readline",
8
+ "code": "import readline from 'readline';\\n\\nconst r1 = readline.createInterface({\\n\\tinput: process.stdin,\\n\\toutput: process.stdout\\n});\\n\\n// Armstrong\\nr1.question('Enter a num : ', (num) => {\\n\\tlet n = parseInt(num);\\n\\tlet arm = 0;\\n\\tlet og = n;\\n\\tlet len = num.length;\\n\\n\\twhile (n > 0) {\\n\\t\\tlet dig = n % 10;\\n\\t\\tarm += Math.pow(dig, len);\\n\\t\\tn = Math.floor(n / 10);\\n\\t}\\n\\n\\tif (og == arm)\\n\\t\\tconsole.log('Is Armstrong!!');\\n\\telse\\n\\t\\tconsole.log('Is Not a Armstrong!!');\\n});\\n\\n// Calculator\\nr1.question('Enter the num : ', (num1) => {\\n\\tlet n1 = parseInt(num1);\\n\\n\\tr1.question('Enter the num : ', (num2) => {\\n\\t\\tlet n2 = parseInt(num2);\\n\\n\\t\\tconsole.log('Addition : ', n1 + n2);\\n\\t\\tconsole.log('Subtraction : ', n1 - n2);\\n\\t\\tconsole.log('Multiplication : ', n1 * n2);\\n\\t\\tconsole.log('Division : ', n1 / n2);\\n\\t});\\n});\\n\\n// Even or Odd\\nr1.question('Enter a num : ', (num) => {\\n\\tlet n = parseInt(num);\\n\\tconsole.log(n % 2 == 0 ? 'Even' : 'Odd');\\n});\\n\\n// Palindrome\\nr1.question('Enter a num : ', (num) => {\\n\\tlet s = num.toString();\\n\\tlet revNum = s.split('').reverse().join('');\\n\\n\\tconsole.log(revNum == s ? 'Is palindrome' : 'Not a palindrome');\\n});\\n\\n// Factorial\\nr1.question('Enter a number: ', (num) => {\\n\\tlet n = parseInt(num);\\n\\tlet fact = 1;\\n\\n\\tfor (let i = 1; i <= n; i++) {\\n\\t\\tfact *= i;\\n\\t}\\n\\n\\tconsole.log('Factorial:', fact);\\n});\\n\\n// Fibonacci\\nr1.question('Enter number of terms: ', (num) => {\\n\\tlet n = parseInt(num);\\n\\tlet a = 0, b = 1;\\n\\n\\tconsole.log(a);\\n\\tconsole.log(b);\\n\\n\\tfor (let i = 2; i < n; i++) {\\n\\t\\tlet next = a + b;\\n\\t\\tconsole.log(next);\\n\\t\\ta = b;\\n\\t\\tb = next;\\n\\t}\\n});\\n\\n// Prime Number\\nr1.question('Enter a number: ', (num) => {\\n\\tlet n = parseInt(num);\\n\\tlet isPrime = true;\\n\\n\\tif (n <= 1) isPrime = false;\\n\\n\\tfor (let i = 2; i <= Math.sqrt(n); i++) {\\n\\t\\tif (n % i === 0) {\\n\\t\\t\\tisPrime = false;\\n\\t\\t\\tbreak;\\n\\t\\t}\\n\\t}\\n\\n\\tconsole.log(isPrime ? 'Prime' : 'Not Prime');\\n});\\n\\n// Sum of Digits\\nr1.question('Enter a number: ', (num) => {\\n\\tlet n = parseInt(num);\\n\\tlet sum = 0;\\n\\n\\twhile (n > 0) {\\n\\t\\tsum += n % 10;\\n\\t\\tn = Math.floor(n / 10);\\n\\t}\\n\\n\\tconsole.log('Sum of digits:', sum);\\n});\\n\\n// Reverse Number\\nr1.question('Enter a number: ', (num) => {\\n\\tlet n = parseInt(num);\\n\\tlet rev = 0;\\n\\n\\twhile (n > 0) {\\n\\t\\tlet digit = n % 10;\\n\\t\\trev = rev * 10 + digit;\\n\\t\\tn = Math.floor(n / 10);\\n\\t}\\n\\n\\tconsole.log('Reversed number:', rev);\\n});\\n\\n// Largest of Three Numbers\\nr1.question('Enter first number: ', (a) => {\\n\\tr1.question('Enter second number: ', (b) => {\\n\\t\\tr1.question('Enter third number: ', (c) => {\\n\\n\\t\\t\\tlet n1 = parseInt(a);\\n\\t\\t\\tlet n2 = parseInt(b);\\n\\t\\t\\tlet n3 = parseInt(c);\\n\\n\\t\\t\\tconsole.log('Largest:', Math.max(n1, n2, n3));\\n\\t\\t});\\n\\t});\\n});\\n\\n// Table\\nr1.question('Enter a number: ', (num) => {\\n\\tlet n = parseInt(num);\\n\\n\\tfor (let i = 1; i <= 10; i++) {\\n\\t\\tconsole.log(`${n} x ${i} = ${n * i}`);\\n\\t}\\n});\\n\\n// Count Digits\\nr1.question('Enter a number: ', (num) => {\\n\\tconsole.log('Total digits:', num.length);\\n});"
9
9
  },
10
- "packet_fragmentation_analysis": {
11
- "title": "Packet Fragmentation Analysis using Wireshark",
12
- "code": "AIM:\\nTo analyze packet fragmentation by changing packet size and observing its effect using Wireshark.\\n\\nStep 1: Open Wireshark\\nLaunch Wireshark\\nSelect active interface (WiFi or Ethernet)\\nClick Start Capture\\n\\nStep 2: Check MTU size\\nOpen Command Prompt and run:\\nnetsh interface ipv4 show subinterfaces\\nNote MTU value (usually 1500 bytes)\\n\\nStep 3: Test without fragmentation\\nping 8.8.8.8 -f -l 1472\\n1472 + 28 header = 1500, fits MTU\\nOutput: Reply received, no fragmentation\\n\\nStep 4: Force fragmentation error\\nping 8.8.8.8 -f -l 2000\\nOutput: Packet needs to be fragmented but DF set\\nMeaning: Packet too large and fragmentation not allowed\\n\\nStep 5: Allow fragmentation\\nping 8.8.8.8 -l 2000\\nPacket is divided into fragments\\nMay observe delay or packet loss\\n\\nStep 6: Analyze in Wireshark\\nApply filter:\\nip.flags.mf == 1 or ip.frag_offset > 0\\n\\nObservation:\\nMultiple packets for single ping\\nFragmented packets visible\\n\\nObservations:\\nFragmented packets have same Identification ID\\nDifferent Fragment Offset values\\nMF flag indicates more fragments\\nLast packet has MF = 0\\n\\nPerformance Impact:\\nMore packets generated\\nIncreased delay\\nPossible packet loss\\n\\nFinal Observation:\\nSmall packet: No fragmentation\\nLarge packet with DF: Error\\nLarge packet without DF: Fragmentation occurs\\n\\nConclusion:\\nIf packet size exceeds MTU, it is divided into smaller fragments, affecting performance\\n\\nOutput:\\nPing command results showing success or error\\nWireshark showing fragmented packets using filter\\n\\nResult:\\nFragmentation observed and analyzed successfully"
10
+ "node_html_template": {
11
+ "title": "Node.js Dynamic HTML Template",
12
+ "code": "<!DOCTYPE html>\\n<html lang=\\\"en\\\">\\n<head>\\n <meta charset=\\\"UTF-8\\\">\\n <title>My App</title>\\n\\n <style>\\n * {\\n margin: 0;\\n padding: 0;\\n box-sizing: border-box;\\n font-family: Arial, sans-serif;\\n }\\n\\n body {\\n background: #f5f7fa;\\n }\\n\\n .navbar {\\n display: flex;\\n justify-content: space-between;\\n padding: 15px 40px;\\n background: #333;\\n color: white;\\n }\\n\\n .navbar a {\\n color: white;\\n margin-left: 20px;\\n text-decoration: none;\\n }\\n\\n .hero {\\n text-align: center;\\n padding: 60px 20px;\\n }\\n\\n .hero h1 {\\n font-size: 36px;\\n }\\n\\n .hero p {\\n margin: 10px 0;\\n }\\n\\n .features {\\n display: flex;\\n justify-content: center;\\n gap: 20px;\\n padding: 40px;\\n }\\n\\n .card {\\n background: white;\\n padding: 20px;\\n width: 200px;\\n text-align: center;\\n border-radius: 8px;\\n }\\n\\n .dynamic {\\n text-align: center;\\n margin: 20px;\\n font-size: 20px;\\n color: #333;\\n }\\n\\n footer {\\n text-align: center;\\n padding: 15px;\\n background: #333;\\n color: white;\\n }\\n </style>\\n</head>\\n\\n<body>\\n\\n <nav class=\\\"navbar\\\">\\n <h2>MyApp</h2>\\n <div>\\n <a href=\\\"/home\\\">Home</a>\\n <a href=\\\"/about\\\">About</a>\\n <a href=\\\"/contact\\\">Contact</a>\\n <a href=\\\"/support\\\">Support</a>\\n </div>\\n </nav>\\n\\n <div class=\\\"dynamic\\\">\\n {{CONTENT}}\\n </div>\\n\\n <section class=\\\"hero\\\">\\n <h1>Simple Node Application</h1>\\n <p>This page is served using a basic Node.js server.</p>\\n </section>\\n\\n <section class=\\\"features\\\">\\n <div class=\\\"card\\\">\\n <h3>Fast</h3>\\n <p>Handles requests efficiently</p>\\n </div>\\n <div class=\\\"card\\\">\\n <h3>Simple</h3>\\n <p>Easy routing and structure</p>\\n </div>\\n <div class=\\\"card\\\">\\n <h3>Flexible</h3>\\n <p>Can be extended easily</p>\\n </div>\\n </section>\\n\\n <footer>\\n <p>Basic Node Server Example</p>\\n </footer>\\n\\n</body>\\n</html>"
13
13
  },
14
- "network_security_acl_port_security": {
15
- "title": "Network Security using ACL and Port Security",
16
- "code": "AIM:\\nTo identify vulnerabilities and secure the network using Access Control List (ACL) and Port Security.\\n\\nStep 1: Topology Setup\\nAdd devices:\\n1 Router (2911)\\n1 Switch (2960)\\n2 PCs\\n\\nStep 2: Connections\\nPC1 FastEthernet0 to Switch Fa0/1 using Copper Straight-Through\\nPC2 FastEthernet0 to Switch Fa0/2 using Copper Straight-Through\\nSwitch Fa0/24 to Router GigabitEthernet0/0\\n\\nStep 3: Configure PCs\\nPC1 IP 192.168.1.10 Mask 255.255.255.0 Gateway 192.168.1.1\\nPC2 IP 192.168.1.20 Mask 255.255.255.0 Gateway 192.168.1.1\\n\\nStep 4: Configure Router\\nenable\\nconfigure terminal\\ninterface g0/0\\nip address 192.168.1.1 255.255.255.0\\nno shutdown\\nexit\\n\\nStep 5: Test Before Security\\nFrom PC2:\\nping 192.168.1.10\\nCommunication should be successful\\n\\nStep 6: Apply ACL\\naccess-list 1 deny 192.168.1.20\\naccess-list 1 permit any\\n\\nApply ACL:\\ninterface g0/0\\nip access-group 1 in\\nexit\\n\\nStep 7: Test After Security\\nFrom PC2:\\nping 192.168.1.10\\nShould fail\\n\\nFrom PC1:\\nping 192.168.1.20\\nShould work\\n\\nStep 8: Configure Port Security on Switch\\nenable\\nconfigure terminal\\ninterface fa0/1\\nswitchport mode access\\nswitchport port-security\\nswitchport port-security maximum 1\\nexit\\n\\nVulnerabilities Identified:\\nNo access control\\nNo device restriction\\nNo traffic filtering\\n\\nSecurity Measures Applied:\\nACL controls communication between devices\\nPort Security restricts number of devices per port\\n\\nAdditional Concepts:\\nIDS detects suspicious activities such as unusual traffic\\nIPsec encrypts data for secure transmission\\n\\nSimulation (Optional):\\nUse Simulation mode\\nFilter ICMP\\nObserve packet drop due to ACL\\n\\nFinal Result:\\nPC2 is blocked\\nPC1 is allowed\\nSwitch ports are secured\\nNetwork is protected successfully"
14
+ "nodejs_routing_server": {
15
+ "title": "Node.js Routing Server with Dynamic HTML Template",
16
+ "code": "const http = require('http');\\nconst fs = require('fs');\\nconst path = require('path');\\n\\nlet counter = 0;\\n\\nconst content = fs.readFileSync('./indexFinal.html', 'utf-8');\\n\\nconst server = http.createServer((req, res) => {\\n\\n\\tcounter++;\\n\\tconsole.log(`Server hit ${counter} times`);\\n\\n\\tlet url = req.url.toLowerCase();\\n\\n\\tif (url === '/style.css') {\\n\\t\\tconst cssPath = path.join(__dirname, 'style.css');\\n\\t\\tconst style = fs.readFileSync(cssPath, 'utf-8');\\n\\n\\t\\tres.writeHead(200, { 'Content-Type': 'text/css' });\\n\\t\\treturn res.end(style);\\n\\t}\\n\\n\\tlet pageContent = '';\\n\\n\\tif (url === '/' || url === '/home') {\\n\\t\\tpageContent = '🏠 Welcome to Home Page';\\n\\t}\\n\\telse if (url === '/about') {\\n\\t\\tpageContent = '📖 About Us Page';\\n\\t}\\n\\telse if (url === '/contact') {\\n\\t\\tpageContent = '📞 Contact Page';\\n\\t}\\n\\telse if (url === '/support') {\\n\\t\\tpageContent = '🛠 Support Page';\\n\\t}\\n\\telse {\\n\\t\\tres.writeHead(404, { 'Content-Type': 'text/html' });\\n\\t\\treturn res.end(content.replace('{{CONTENT}}', '❌ 404 Page Not Found'));\\n\\t}\\n\\n\\tres.writeHead(200, { 'Content-Type': 'text/html' });\\n\\tres.end(content.replace('{{CONTENT}}', pageContent));\\n\\n});\\n\\nserver.listen(3000, '127.0.0.1', () => {\\n\\tconsole.log('Server running at http://127.0.0.1:3000');\\n});"
17
17
  },
18
- "ip_spoofing_security_practical": {
19
- "title": "IP Spoofing Attack and Prevention using ACL and uRPF",
20
- "code": "AIM:\\nTo demonstrate IP Spoofing attack and implement security measures to prevent unauthorized access.\\n\\nStep 1: Topology Setup\\nDevices required:\\n1 Router (2911)\\n1 Switch (2960)\\nPC1 (Trusted user)\\nPC2 (Attacker)\\n1 Server\\n\\nConnections:\\nPC1 to Switch Fa0/1\\nPC2 to Switch Fa0/2\\nSwitch Fa0/24 to Router G0/0\\nServer to Router G0/1\\n\\nStep 2: IP Configuration\\nPC1 IP 192.168.1.10 Gateway 192.168.1.1\\nPC2 IP 192.168.1.20 Gateway 192.168.1.1\\nServer IP 10.0.0.2 Gateway 10.0.0.1\\n\\nStep 3: Configure Router\\nenable\\nconfigure terminal\\n\\ninterface g0/0\\nip address 192.168.1.1 255.255.255.0\\nno shutdown\\nexit\\n\\ninterface g0/1\\nip address 10.0.0.1 255.255.255.0\\nno shutdown\\nexit\\n\\nStep 4: Configure Routing\\nip route 10.0.0.0 255.255.255.0 10.0.0.1\\n\\nStep 5: Apply Trust-Based ACL\\naccess-list 10 permit 192.168.1.10\\naccess-list 10 deny any\\n\\ninterface g0/0\\nip access-group 10 in\\n\\nStep 6: Test Before Attack\\nFrom PC1:\\nping 10.0.0.2 (should work)\\n\\nFrom PC2:\\nping 10.0.0.2 (should fail)\\n\\nStep 7: Simulate IP Spoofing\\nChange PC2 IP to 192.168.1.10\\n\\nTest again:\\nping 10.0.0.2 (should work)\\n\\nStep 8: Impact\\nUnauthorized access\\nSecurity bypass\\nFake identity\\n\\nStep 9: Countermeasure 1 Anti-Spoofing ACL\\nip access-list extended ANTI-SPOOF\\ndeny ip 192.168.1.0 0.0.0.255 any\\npermit ip any any\\n\\ninterface g0/1\\nip access-group ANTI-SPOOF in\\n\\nStep 10: Countermeasure 2 uRPF\\ninterface g0/0\\nip verify unicast source reachable-via rx\\n\\nStep 11: Switch Port Security\\nenable\\nconfigure terminal\\n\\ninterface fa0/1\\nswitchport mode access\\nswitchport port-security\\nswitchport port-security maximum 1\\nswitchport port-security mac-address sticky\\nswitchport port-security violation shutdown\\n\\nFinal Understanding:\\nBefore ACL everyone allowed\\nACL allows only trusted IP\\nSpoofing bypasses security\\nuRPF blocks spoofed packets\\n\\nConclusion:\\nIP-based trust is not secure and must be verified using mechanisms like uRPF and port security\\n\\nResult:\\nAttack simulated successfully\\nVulnerability identified\\nSecurity measures implemented"
18
+ "nodejs_routing_with_api": {
19
+ "title": "Node.js Server with Routing and Product API",
20
+ "code": "const http = require('http');\\nconst fs = require('fs');\\n\\nlet counter = 0;\\n\\nconst content = fs.readFileSync('./Template/index.html', 'utf-8');\\n\\nconst server = http.createServer((request, response) => {\\n\\n\\tcounter++;\\n\\tconsole.log(`Server started ${counter} times`);\\n\\n\\tlet path = request.url.toLowerCase();\\n\\n\\tif (path === '/' || path === '/home') {\\n\\t\\tresponse.writeHead(200, { 'Content-Type': 'text/html' });\\n\\t\\tresponse.end(content.replace('{{CONTENT}}', 'You are in home page'));\\n\\t}\\n\\n\\telse if (path === '/about') {\\n\\t\\tresponse.writeHead(200, { 'Content-Type': 'text/html' });\\n\\t\\tresponse.end(content.replace('{{CONTENT}}', 'You are in about us page'));\\n\\t}\\n\\n\\telse if (path === '/contact') {\\n\\t\\tresponse.writeHead(200, { 'Content-Type': 'text/html' });\\n\\t\\tresponse.end(content.replace('{{CONTENT}}', 'You are in contact page'));\\n\\t}\\n\\n\\telse if (path === '/support') {\\n\\t\\tresponse.writeHead(200, { 'Content-Type': 'text/html' });\\n\\t\\tresponse.end(content.replace('{{CONTENT}}', 'Support me aagya bhai'));\\n\\t}\\n\\n\\telse if (path === '/product') {\\n\\n\\t\\tfs.readFile('./data/products.json', 'utf-8', (error, jsonData) => {\\n\\n\\t\\t\\tif (error) {\\n\\t\\t\\t\\tresponse.writeHead(500, { 'Content-Type': 'text/plain' });\\n\\t\\t\\t\\treturn response.end('Error reading JSON file');\\n\\t\\t\\t}\\n\\n\\t\\t\\tresponse.writeHead(200, { 'Content-Type': 'application/json' });\\n\\t\\t\\tresponse.end(jsonData);\\n\\t\\t});\\n\\t}\\n\\n\\telse {\\n\\t\\tresponse.writeHead(404, { 'Content-Type': 'text/html' });\\n\\t\\tresponse.end(content.replace('{{CONTENT}}', 'Error : 404 NOT FOUND'));\\n\\t}\\n\\n});\\n\\nserver.listen(3000, '127.0.0.1', () => {\\n\\tconsole.log('Server running at http://127.0.0.1:3000');\\n});"
21
21
  },
22
- "udp_acl_security_practical": {
23
- "title": "UDP Traffic Control using Access Control List (ACL)",
24
- "code": "AIM:\\nTo allow normal UDP communication and block unwanted UDP traffic using ACL.\\n\\nStep 1: Build the Network\\nDevices required:\\n1 Router (2911)\\n1 Switch (2960)\\nPC1 (Client)\\nPC2 (Attacker)\\n1 Server\\n\\nConnections:\\nPC1 FastEthernet0 to Switch Fa0/1\\nPC2 FastEthernet0 to Switch Fa0/2\\nServer FastEthernet0 to Switch Fa0/3\\nSwitch Fa0/24 to Router GigabitEthernet0/0\\n\\nStep 2: IP Configuration\\nPC1 IP 192.168.1.10 Gateway 192.168.1.1\\nPC2 IP 192.168.1.30 Gateway 192.168.1.1\\nServer IP 192.168.1.20\\nSubnet Mask 255.255.255.0\\n\\nStep 3: Configure Router\\nenable\\nconfigure terminal\\ninterface g0/0\\nip address 192.168.1.1 255.255.255.0\\nno shutdown\\nexit\\n\\nStep 4: Enable UDP Service on Server\\nOpen Server -> Services -> DNS\\nTurn DNS ON\\nAdd entry:\\nName example.com\\nAddress 192.168.1.20\\n\\nStep 5: Test UDP Communication\\nFrom PC1:\\nnslookup example.com 192.168.1.20\\nUDP communication should work\\n\\nStep 6: Apply ACL to Block Attacker\\nRouter(config)# access-list 100 deny udp host 192.168.1.30 any\\nRouter(config)# access-list 100 permit ip any any\\n\\nApply ACL:\\ninterface g0/0\\nip access-group 100 in\\nexit\\n\\nStep 7: Test After ACL\\nFrom PC2:\\nnslookup example.com 192.168.1.20 (should fail)\\n\\nFrom PC1:\\nnslookup example.com 192.168.1.20 (should work)\\n\\nStep 8: Block DNS Service (Port-Based ACL)\\nRouter(config)# access-list 101 deny udp any any eq 53\\nRouter(config)# access-list 101 permit ip any any\\n\\nApply:\\ninterface g0/0\\nip access-group 101 in\\nexit\\n\\nTest:\\nFrom PC1:\\nnslookup example.com 192.168.1.20 (should fail)\\n\\nStep 9: Important Concept\\nIf all devices are in same network, traffic bypasses router\\nCommunication becomes PC -> Switch -> Server\\nACL will not work\\n\\nStep 10: Fix Topology\\nChange Server network:\\nServer IP 10.0.0.2 Gateway 10.0.0.1\\n\\nConfigure Router:\\ninterface g0/1\\nip address 10.0.0.1 255.255.255.0\\nno shutdown\\n\\nNow traffic flows through router:\\nPC -> Router -> Server\\nACL works correctly\\n\\nConcepts:\\nUDP is fast and connectionless protocol\\nACL filters traffic based on rules\\nPort 53 is used for DNS\\nRouter must be in path for ACL to work\\n\\nResult:\\nUDP communication tested\\nAttacker blocked using ACL\\nDNS service blocked using port-based ACL\\nNetwork secured successfully"
22
+ "express_get_product_api": {
23
+ "title": "Express Server with Product API",
24
+ "code": "const express = require('express');\\nconst fs = require('fs');\\n\\nconst app = express();\\n\\nfunction getProducts() {\\n\\tconst data = fs.readFileSync('./product.json', 'utf-8');\\n\\treturn JSON.parse(data).products;\\n}\\n\\napp.get('/', (req, res) => {\\n\\tres.status(200).send('You are on home page');\\n});\\n\\napp.get('/about', (req, res) => {\\n\\tres.status(200).send('You are on about page');\\n});\\n\\napp.get('/product', (req, res) => {\\n\\tconst products = getProducts();\\n\\n\\tres.status(200).json({\\n\\t\\tstatus: 'success',\\n\\t\\tresults: products.length,\\n\\t\\tdata: products\\n\\t});\\n});\\n\\napp.get('/product/:id', (req, res) => {\\n\\tconst products = getProducts();\\n\\tconst id = parseInt(req.params.id);\\n\\n\\tconst product = products.find(el => el.id === id);\\n\\n\\tif (!product) {\\n\\t\\treturn res.status(404).json({\\n\\t\\t\\tstatus: 'fail',\\n\\t\\t\\tmessage: 'Product not found'\\n\\t\\t});\\n\\t}\\n\\n\\tres.status(200).json({\\n\\t\\tstatus: 'success',\\n\\t\\tdata: product\\n\\t});\\n});\\n\\napp.get('/contact', (req, res) => {\\n\\tres.status(200).send('You are on contact page');\\n});\\n\\napp.listen(3000, () => {\\n\\tconsole.log('Server running on port 3000');\\n});"
25
25
  },
26
- "udp_acl_dns_security_practical": {
27
- "title": "UDP DNS Communication with ACL Security",
28
- "code": "AIM:\\nCreate a network, enable DNS (UDP), allow normal user, and block attacker using ACL.\\n\\nStep 1: Topology\\nPC1 (Client) and PC2 (Attacker) connected to Switch\\nSwitch connected to Router G0/0\\nRouter G0/1 connected to Server\\n\\nStep 2: Connections\\nUse Copper Straight-Through cables\\nPC1 to Switch Fa0/1\\nPC2 to Switch Fa0/2\\nSwitch to Router G0/0\\nRouter G0/1 to Server\\nAll links should be active\\n\\nStep 3: IP Configuration\\nPC1 IP 192.168.1.10 Mask 255.255.255.0 Gateway 192.168.1.1 DNS 10.0.0.2\\nPC2 IP 192.168.1.30 Mask 255.255.255.0 Gateway 192.168.1.1 DNS 10.0.0.2\\nServer IP 10.0.0.2 Mask 255.255.255.0 Gateway 10.0.0.1\\n\\nStep 4: Router Configuration\\nenable\\nconfigure terminal\\n\\ninterface g0/0\\nip address 192.168.1.1 255.255.255.0\\nno shutdown\\nexit\\n\\ninterface g0/1\\nip address 10.0.0.1 255.255.255.0\\nno shutdown\\nexit\\n\\nStep 5: Enable DNS on Server\\nOpen Server -> Services -> DNS\\nTurn DNS ON\\nAdd entry:\\nName example.com\\nAddress 10.0.0.2\\n\\nStep 6: Initial Testing\\nFrom PC1:\\nping 10.0.0.2\\nThis builds ARP\\n\\nThen:\\nnslookup example.com\\nShould work successfully\\n\\nStep 7: Apply ACL Security\\nconfigure terminal\\n\\naccess-list 101 deny udp host 192.168.1.30 any\\naccess-list 101 permit ip any any\\n\\ninterface g0/0\\nip access-group 101 in\\nexit\\n\\nStep 8: Final Testing\\nFrom PC1:\\nnslookup example.com\\nShould work\\n\\nFrom PC2:\\nnslookup example.com\\nShould fail\\n\\nConcepts:\\nRouter must be in path for ACL to work\\nDNS uses UDP port 53\\nFirst ping builds ARP and avoids timeout\\nACL filters traffic based on rules\\n\\nFinal Result:\\nPC1 allowed\\nPC2 blocked\\nDNS working\\nACL applied successfully"
26
+ "express_post_product_api": {
27
+ "title": "Express API to Add Product (POST Request)",
28
+ "code": "const express = require('express');\\nconst fs = require('fs');\\n\\nconst app = express();\\n\\napp.use(express.json());\\n\\nfunction getProducts() {\\n\\tconst data = fs.readFileSync('./product.json', 'utf-8');\\n\\treturn JSON.parse(data).products;\\n}\\n\\nfunction saveProducts(products) {\\n\\tfs.writeFileSync('./product.json', JSON.stringify({ products }, null, 2));\\n}\\n\\napp.post('/product', (req, res) => {\\n\\n\\tconst products = getProducts();\\n\\tconst newProduct = req.body;\\n\\n\\tif (!newProduct.name || !newProduct.price) {\\n\\t\\treturn res.status(400).json({\\n\\t\\t\\tstatus: 'fail',\\n\\t\\t\\tmessage: 'Name and price are required'\\n\\t\\t});\\n\\t}\\n\\n\\tconst newId = products.length > 0\\n\\t\\t? products[products.length - 1].id + 1\\n\\t\\t: 1;\\n\\n\\tnewProduct.id = newId;\\n\\n\\tproducts.push(newProduct);\\n\\n\\tsaveProducts(products);\\n\\n\\tres.status(201).json({\\n\\t\\tstatus: 'success',\\n\\t\\tmessage: 'Product added successfully',\\n\\t\\tdata: newProduct\\n\\t});\\n});\\n\\napp.listen(3000, () => {\\n\\tconsole.log('Server running on port 3000');\\n});"
29
29
  },
30
- "dns_udp_hijacking_practical": {
31
- "title": "DNS UDP Hijacking Simulation and Prevention",
32
- "code": "AIM:\\nSimulate a DNS-based UDP hijacking scenario, observe its impact on the client, and apply basic protection.\\n\\nStep 1: Topology Setup\\nConnect devices using Copper Straight-Through:\\nPC1 to Switch\\nPC2 to Switch\\nServer to Switch\\nSwitch to Router\\nEnsure all connections are active\\n\\nStep 2: IP Configuration\\nPC1 IP 192.168.1.10 Mask 255.255.255.0 Gateway 192.168.1.1 DNS 192.168.1.100\\nPC2 IP 192.168.1.20 Gateway 192.168.1.1\\nServer IP 192.168.1.100 Gateway 192.168.1.1\\n\\nStep 3: Router Configuration\\nenable\\nconfigure terminal\\ninterface g0/0\\nip address 192.168.1.1 255.255.255.0\\nno shutdown\\nexit\\n\\nStep 4: Enable DNS on Real Server\\nOpen Server -> Services -> DNS\\nTurn DNS ON\\nAdd entry:\\nexample.com maps to 192.168.1.100\\n\\nStep 5: Test Normal Output\\nFrom PC1:\\nnslookup example.com\\nExpected result:\\nName example.com\\nAddress 192.168.1.100\\n\\nStep 6: Simulate Attack\\nTurn OFF real server\\nOn PC2 change IP to 192.168.1.100\\nEnable DNS on PC2\\nAdd entry:\\nexample.com maps to 5.5.5.5\\n\\nStep 7: Test Attack Output\\nFrom PC1:\\nnslookup example.com\\nExpected result:\\nName example.com\\nAddress 5.5.5.5\\n\\nObservation:\\nBefore attack DNS resolves to 192.168.1.100\\nAfter attack DNS resolves to 5.5.5.5\\nClient is misled\\n\\nStep 8: Apply Basic Protection using Port Security\\nOn Switch CLI:\\nenable\\nconfigure terminal\\ninterface fa0/2\\nswitchport mode access\\nswitchport port-security\\nswitchport port-security maximum 1\\nswitchport port-security mac-address sticky\\nswitchport port-security violation shutdown\\nexit\\n\\nStep 9: Final Check\\nAttempt attack again\\nPort security blocks attacker or shuts down port\\n\\nOutput Observation Methods:\\nCommand Line:\\nUse nslookup example.com before and after attack\\n\\nSimulation Mode:\\nSelect Simulation\\nFilter DNS or UDP\\nRun nslookup\\nObserve source IP, destination IP, and UDP port 53\\n\\nConclusion:\\nDNS over UDP can be exploited by spoofing\\nClient blindly trusts DNS response\\nSecurity measures like port security help prevent attacks\\n\\nResult:\\nAttack successfully simulated\\nImpact observed\\nBasic protection applied"
30
+ "express_patch_product_api": {
31
+ "title": "Express API to Update Product (PATCH Request)",
32
+ "code": "const express = require('express');\\nconst fs = require('fs');\\n\\nconst app = express();\\n\\napp.use(express.json());\\n\\nfunction getProducts() {\\n\\tconst data = fs.readFileSync('./product.json', 'utf-8');\\n\\treturn JSON.parse(data).products;\\n}\\n\\nfunction saveProducts(products) {\\n\\tfs.writeFileSync('./product.json', JSON.stringify({ products }, null, 2));\\n}\\n\\napp.patch('/product/:id', (req, res) => {\\n\\n\\tconst products = getProducts();\\n\\tconst id = parseInt(req.params.id);\\n\\n\\tconst product = products.find(el => el.id === id);\\n\\n\\tif (!product) {\\n\\t\\treturn res.status(404).json({\\n\\t\\t\\tstatus: 'fail',\\n\\t\\t\\tmessage: 'Product not found'\\n\\t\\t});\\n\\t}\\n\\n\\tif (req.body.id) {\\n\\t\\treturn res.status(400).json({\\n\\t\\t\\tstatus: 'fail',\\n\\t\\t\\tmessage: 'Cannot update product id'\\n\\t\\t});\\n\\t}\\n\\n\\tObject.assign(product, req.body);\\n\\n\\tsaveProducts(products);\\n\\n\\tres.status(200).json({\\n\\t\\tstatus: 'success',\\n\\t\\tmessage: 'Product updated successfully',\\n\\t\\tdata: product\\n\\t});\\n});\\n\\napp.listen(3000, () => {\\n\\tconsole.log('Server running on port 3000');\\n});"
33
33
  },
34
- "dos_attack_simulation_practical": {
35
- "title": "Denial of Service (DoS) Attack Simulation and Prevention",
36
- "code": "AIM:\\nSimulate a DoS condition using continuous requests, observe its impact on a server, and apply prevention techniques.\\n\\nStep 1: Topology\\nDevices:\\nPC1, PC2, PC3, Server connected to Switch\\nSwitch connected to Router G0/0\\nEnsure all connections are active\\n\\nStep 2: IP Configuration\\nPC1 IP 192.168.1.10\\nPC2 IP 192.168.1.20\\nPC3 IP 192.168.1.30\\nServer IP 192.168.1.100\\nMask 255.255.255.0\\nGateway 192.168.1.1\\n\\nStep 3: Router Configuration\\nenable\\nconfigure terminal\\ninterface g0/0\\nip address 192.168.1.1 255.255.255.0\\nno shutdown\\nexit\\n\\nStep 4: Enable Server Service\\nOpen Server -> Services -> HTTP\\nTurn HTTP ON\\n\\nStep 5: Normal Test\\nFrom PC1:\\nping 192.168.1.100\\nStable replies indicate normal operation\\n\\nStep 6: Simulate DoS Attack\\nFrom PC2:\\nping 192.168.1.100 -t\\n\\nFrom PC3:\\nping 192.168.1.100 -t\\n\\nContinuous traffic is generated\\n\\nStep 7: Observe Impact\\nFrom PC1:\\nping 192.168.1.100\\n\\nExpected results:\\nRequest timed out\\nHigh delay\\nPacket loss\\n\\nIndicates server overload and network congestion\\n\\nStep 8: Important Concept\\nIf all devices are in same network, traffic flows directly\\nPC -> Switch -> Server\\nRouter is bypassed\\nACL on router will not work\\n\\nStep 9: Apply Switch Port Security\\nenable\\nconfigure terminal\\n\\ninterface fa0/2\\nswitchport port-security\\nswitchport port-security maximum 1\\nswitchport port-security violation shutdown\\nexit\\n\\ninterface fa0/3\\nswitchport port-security\\nswitchport port-security maximum 1\\nswitchport port-security violation shutdown\\nexit\\n\\nLimits attacker behavior\\n\\nStep 10: Improved Topology for Router Control\\nChange Server network:\\nServer IP 10.0.0.2 Gateway 10.0.0.1\\n\\nAdd router interface:\\ninterface g0/1\\nip address 10.0.0.1 255.255.255.0\\nno shutdown\\n\\nTraffic now passes through router\\n\\nStep 11: Apply ACL Protection\\nip access-list extended BLOCK_ICMP\\npermit icmp host 192.168.1.10 host 10.0.0.2\\ndeny icmp any any\\n\\ninterface g0/0\\nip access-group BLOCK_ICMP in\\n\\nStep 12: Final Testing\\nFrom PC1:\\nping 10.0.0.2 (should work)\\n\\nFrom PC2 and PC3:\\nping 10.0.0.2 (should fail)\\n\\nOutput Observation:\\nCommand Line:\\nCompare ping before and during attack\\n\\nSimulation Mode:\\nFilter ICMP\\nObserve multiple packets and congestion\\n\\nConclusion:\\nDoS attack floods server with requests causing delay and packet loss\\nSwitch port security and ACL help control traffic\\n\\nResult:\\nAttack simulated\\nImpact observed\\nProtection applied successfully"
34
+ "express_delete_product_api": {
35
+ "title": "Express API to Delete Product (DELETE Request)",
36
+ "code": "const express = require('express');\\nconst fs = require('fs');\\n\\nconst app = express();\\n\\napp.use(express.json());\\n\\nfunction getProducts() {\\n\\tconst data = fs.readFileSync('./product.json', 'utf-8');\\n\\treturn JSON.parse(data).products;\\n}\\n\\nfunction saveProducts(products) {\\n\\tfs.writeFileSync('./product.json', JSON.stringify({ products }, null, 2));\\n}\\n\\napp.delete('/product/:id', (req, res) => {\\n\\n\\tconst products = getProducts();\\n\\tconst id = parseInt(req.params.id);\\n\\n\\tconst index = products.findIndex(el => el.id === id);\\n\\n\\tif (index === -1) {\\n\\t\\treturn res.status(404).json({\\n\\t\\t\\tstatus: 'fail',\\n\\t\\t\\tmessage: 'Product not found'\\n\\t\\t});\\n\\t}\\n\\n\\tconst deletedProduct = products.splice(index, 1);\\n\\n\\tsaveProducts(products);\\n\\n\\tres.status(200).json({\\n\\t\\tstatus: 'success',\\n\\t\\tmessage: 'Product deleted successfully',\\n\\t\\tdata: deletedProduct[0]\\n\\t});\\n});\\n\\napp.listen(3000, () => {\\n\\tconsole.log('Server running on port 3000');\\n});"
37
+ },
38
+ "express_put_product_api": {
39
+ "title": "Express API to Replace Product (PUT Request)",
40
+ "code": "const express = require('express');\\nconst fs = require('fs');\\n\\nconst app = express();\\n\\napp.use(express.json());\\n\\nfunction getProducts() {\\n\\tconst data = fs.readFileSync('./product.json', 'utf-8');\\n\\treturn JSON.parse(data).products;\\n}\\n\\nfunction saveProducts(products) {\\n\\tfs.writeFileSync('./product.json', JSON.stringify({ products }, null, 2));\\n}\\n\\napp.put('/product/:id', (req, res) => {\\n\\n\\tconst products = getProducts();\\n\\tconst id = parseInt(req.params.id);\\n\\n\\tconst index = products.findIndex(el => el.id === id);\\n\\n\\tif (index === -1) {\\n\\t\\treturn res.status(404).json({\\n\\t\\t\\tstatus: 'fail',\\n\\t\\t\\tmessage: 'Product not found'\\n\\t\\t});\\n\\t}\\n\\n\\tconst newData = req.body;\\n\\n\\tif (!newData.name || !newData.price) {\\n\\t\\treturn res.status(400).json({\\n\\t\\t\\tstatus: 'fail',\\n\\t\\t\\tmessage: 'Name and price are required'\\n\\t\\t});\\n\\t}\\n\\n\\tnewData.id = id;\\n\\n\\tproducts[index] = newData;\\n\\n\\tsaveProducts(products);\\n\\n\\tres.status(200).json({\\n\\t\\tstatus: 'success',\\n\\t\\tmessage: 'Product replaced successfully',\\n\\t\\tdata: newData\\n\\t});\\n});\\n\\napp.listen(3000, () => {\\n\\tconsole.log('Server running on port 3000');\\n});"
41
+ },
42
+ "nodejs_chalk_styling": {
43
+ "title": "Node.js Console Styling using Chalk",
44
+ "code": "const chalk = require('chalk');\\n\\nconsole.log(chalk.red.bold('Error!'));\\nconsole.log(chalk.green.underline('Success!'));\\nconsole.log(chalk.blue.italic('Info message'));\\nconsole.log(chalk.white.bgBlue.bold(' Important Message '));\\nconsole.log(chalk.black.bgYellow(' Warning Block '));\\nconsole.log(chalk.bgRed.white.bold(' Critical Error '));\\nconsole.log(chalk.rgb(255, 136, 0)('Custom Orange Text'));\\nconsole.log(chalk.hex('#00FFAA')('Hex Color Text'));\\nconsole.log(chalk.bgHex('#FF5733').white('Styled Background'));\\n\\nconsole.log(\\n\\tchalk.blue('Hello ' + chalk.yellow.bold('World') + '!')\\n);\\n\\nconsole.log(\\n\\tchalk.red('H') +\\n\\tchalk.yellow('e') +\\n\\tchalk.green('l') +\\n\\tchalk.blue('l') +\\n\\tchalk.magenta('o')\\n);"
37
45
  }
38
46
  }
39
47
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chiwormjava",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"