{"id":1412,"date":"2015-01-05T20:34:51","date_gmt":"2015-01-06T02:34:51","guid":{"rendered":"http:\/\/blog.supportpro.com\/?p=1412"},"modified":"2019-03-07T18:10:26","modified_gmt":"2019-03-08T00:10:26","slug":"installation-of-portsentry","status":"publish","type":"post","link":"https:\/\/www.supportpro.com\/blog\/installation-of-portsentry\/","title":{"rendered":"Installation of  PortsEntry"},"content":{"rendered":"<p><strong>Portsentry<\/strong> is a tool to detect port scans and log it. Once a host is targeted by an attacker, a port scan is almost always performed.<\/p>\n<p>PortSentry detects such scans by monitoring the unused ports on the host. Upon a connection attempt to one of the unused ports, PortSentry is alerted and has the ability to issue a number of commands in response to the scan.<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Installation<\/strong><\/span><\/p>\n<p><em><span style=\"line-height: 1.5em;\"># cd \/usr\/src\/<\/span><\/em><\/p>\n<p><em># wget http:\/\/sourceforge.net\/projects\/sentrytools\/files\/latest\/download<!--more--><\/em><\/p>\n<p><em># tar -xzvf portsentry-1.2.tar.gz<\/em><\/p>\n<p><em># cd portsentry_beta\/<\/em><\/p>\n<p><em># make linux<\/em><\/p>\n<p>You may face the following error upon installation<\/p>\n<p>.\/portsentry.c:1584:11: warning: missing terminating &#8221; character<\/p>\n<p>.\/portsentry.c: In function \u201a\u00c4\u00f2Usage\u201a\u00c4\u00f4:<\/p>\n<p>.\/portsentry.c:1584: error: missing terminating &#8221; character<\/p>\n<p>.\/portsentry.c:1585: error: \u201a\u00c4\u00f2sourceforget\u201a\u00c4\u00f4 undeclared (first use in this function)<\/p>\n<p>.\/portsentry.c:1585: error: (Each undeclared identifier is reported only once<\/p>\n<p>.\/portsentry.c:1585: error: for each function it appears in.)<\/p>\n<p>.\/portsentry.c:1585: error: expected \u201a\u00c4\u00f2)\u201a\u00c4\u00f4 before \u201a\u00c4\u00f2dot\u201a\u00c4\u00f4<\/p>\n<p>.\/portsentry.c:1585: error: stray \u201a\u00c4\u00f2\\\u201a\u00c4\u00f4 in program<\/p>\n<p>.\/portsentry.c:1585:24: warning: missing terminating &#8221; character<\/p>\n<p>.\/portsentry.c:1585: error: missing terminating &#8221; character<\/p>\n<p>.\/portsentry.c:1595: error: expected \u201a\u00c4\u00f2;\u201a\u00c4\u00f4 before \u201a\u00c4\u00f2}\u201a\u00c4\u00f4 token<\/p>\n<p>.\/portsentry_io.c: In function \u201a\u00c4\u00f2ConfigTokenRetrieve\u201a\u00c4\u00f4:<\/p>\n<p>.\/portsentry_io.c:321: warning: cast from pointer to integer of different size<\/p>\n<p>.\/portsentry_io.c:324: warning: cast from pointer to integer of different size<\/p>\n<p>.\/portsentry_io.c: In function \u201a\u00c4\u00f2IsBlocked\u201a\u00c4\u00f4:<\/p>\n<p>.\/portsentry_io.c:670: warning: cast from pointer to integer of different size<\/p>\n<p>.\/portsentry_io.c: In function \u201a\u00c4\u00f2SubstString\u201a\u00c4\u00f4:<\/p>\n<p>.\/portsentry_io.c:727: warning: cast from pointer to integer of different size<\/p>\n<p>make: *** [linux] Error 1<\/p>\n<p>To resolve the error, please follow the step<\/p>\n<p>&#8212;&#8212;&#8212;<\/p>\n<p>Open portsentry.c and look for the line 1584. There will be a extra carriage return breaking the line and you have to delete the carriage return and make single line<\/p>\n<p>Then proceed with the installation.<\/p>\n<p>After the successful installation, please edit the configuration file <em>\/usr\/local\/psionic\/portsentry\/portsentry.conf<\/em> file to enable route drop.<\/p>\n<p>1. Find and uncomment the KILL_ROUTE option that corresponds to your operating system<\/p>\n<p>2. Uncomment the line<\/p>\n<p>KILL_ROUTE=&#8221;\/sbin\/iptables -I INPUT -s $TARGET$ -j DROP&#8221;<\/p>\n<p>This will drop all packets originating from an attacker&#8217;s IP address and log future connection attempts.<\/p>\n<p>3. Uncomment the entries TCP_PORTS and UDP_PORTS and add the ports to be scanned.<\/p>\n<p><strong>TCP_PORTS<\/strong>=&#8221;1,7,9,11,15,70,79,80,109,110,111,119,138,139,143,512,513,514,515,540,635,1080,1524,2000,2001,4000,4001,5742,6000,6001,6667,12345,12346,20034,27665,30303,32771,32772,32773,32774,31337,40421,40425,49724&#8243;<\/p>\n<p><strong>UDP_PORTS<\/strong>=&#8221;1,7,9,66,67,68,69,111,137,138,161,162,474,513,517,518,635,640,641,666,700,2049,31335,27444,34555,32770,32771,32772,32773,32774,31337,54321&#8243;<\/p>\n<p>4. Ports can also be manually excluded via the parameters<\/p>\n<p>ADVANCED_EXCLUDE_UDP and ADVANCED_EXCLUDE_TCP<\/p>\n<p>5. If you want to whitelist a particular IP, please add it under the file<\/p>\n<p><em>\/usr\/local\/psionic\/portsentry\/portsentry.ignore<\/em><\/p>\n<p>This file contains the IP addresses that PortSentry should ignore if it connects to a monitored port.<\/p>\n<p>The portsentry.ignore file is simply a list of IP addresses along with the associated netmask in &#8220;slash&#8221; notation as shown below<\/p>\n<p>172.16.88.0\/24 10.16.17.0\/24 192.168.0.0\/16 127.0.0.1\/32<\/p>\n<p>PortSentry can now be enabled.<\/p>\n<p>First, we start up the TCP port monitor and then UDP port monitor<br \/>\n<em># \/usr\/local\/psionic\/portsentry\/portsentry -atcp<\/em><\/p>\n<p><em># \/usr\/local\/psionic\/portsentry\/portsentry -audp<\/em><\/p>\n<p>Afterwards, when an IP is blocked on port scan, it will be recorded on the log file\u00a0<em>\/var\/log\/secure.<\/em><\/p>\n<p><strong><span style=\"line-height: 1.5em;\">Need expert assistance?<\/span><\/strong><\/p>\n<p><a href=\"https:\/\/www.supportpro.com\"><strong>SupportPRO<\/strong><\/a> has a team of well experienced professionals. We can assist you in the installation and configuration of Portsentry in your server. Feel free to contact us if you need assistance.<br \/>\nIf you require help, <a href=\"https:\/\/www.supportpro.com\/requestquote.php\">contact SupportPRO Server Admin<\/a><\/p>\n<p style=\"text-align: center;\"><!--HubSpot Call-to-Action Code --><span id=\"hs-cta-wrapper-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-wrapper\"><span id=\"hs-cta-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-node hs-cta-9d590242-d641-4383-94b4-8cfd62f0af6b\"><!-- [if lte IE 8]><\/p>\n\n\n\n\n\n<div id=\"hs-cta-ie-element\"><\/div>\n\n\n<![endif]--><a href=\"https:\/\/cta-redirect.hubspot.com\/cta\/redirect\/2725694\/9d590242-d641-4383-94b4-8cfd62f0af6b\"><img decoding=\"async\" id=\"hs-cta-img-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-img\" style=\"border-width: 0px;\" src=\"https:\/\/no-cache.hubspot.com\/cta\/default\/2725694\/9d590242-d641-4383-94b4-8cfd62f0af6b.png\" alt=\"Server not running properly? Get A FREE Server Checkup By Expert Server Admins - $125 Value\" \/><\/a><\/span><script charset=\"utf-8\" src=\"https:\/\/js.hscta.net\/cta\/current.js\"><\/script><script type=\"text\/javascript\"> hbspt.cta.load(2725694, '9d590242-d641-4383-94b4-8cfd62f0af6b', {}); <\/script><\/span><!-- end HubSpot Call-to-Action Code --><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Portsentry is a tool to detect port scans and log it. Once a host is targeted by an attacker, a port scan is almost always performed. PortSentry detects such scans&hellip;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[5,6,4,3],"tags":[],"class_list":["post-1412","post","type-post","status-publish","format-standard","hentry","category-general-topics","category-linux-basics","category-server-security","category-technical-articles"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/1412","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/comments?post=1412"}],"version-history":[{"count":5,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/1412\/revisions"}],"predecessor-version":[{"id":3097,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/1412\/revisions\/3097"}],"wp:attachment":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/media?parent=1412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/categories?post=1412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/tags?post=1412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}