Tuesday, June 27, 2017

Nginx Configuration to block SQL Injection and similar attacks

location ~* "(eval\()" { deny all; }
location ~* "(127\.0\.0\.1)" { deny all; }
location ~* "([a-z0-9]{2000})" { deny all; }
location ~* "(javascript\:)(.*)(\;)" { deny all; }
location ~* "(base64_encode)(.*)(\()" { deny all; }
location ~* "(GLOBALS|REQUEST)(=|\[|%)" { deny all; }
location ~* "(<|%3C).*script.*(>|%3)" { deny all; }
location ~ "(\\|\.\.\.|\.\./|~|`|<|>|\|)" { deny all; }
location ~* "(boot\.ini|etc/passwd|self/environ)" { deny all; }
location ~* "(thumbs?(_editor|open)?|tim(thumb)?)\.php" { deny all; }
location ~* "(\'|\")(.*)(drop|insert|md5|select|union)" { deny all; }
location ~* "(https?|ftp|php):/" { deny all; }
location ~* "(=\\\'|=\\%27|/\\\'/?)\." { deny all; }
location ~* "/(\$(\&)?|\*|\"|\.|,|&|&amp;?)/?$" { deny all; }
location ~ "(\{0\}|\(/\(|\.\.\.|\+\+\+|\\\"\\\")" { deny all; }
location ~ "(~|`|<|>|:|;|%|\\|\s|\{|\}|\[|\]|\|)" { deny all; }
location ~* "/(=|\$&|_mm|(wp-)?config\.|cgi-|etc/passwd|muieblack)" { deny all; }
location ~* "(&pws=0|_vti_|\(null\)|\{\$itemURL\}|echo(.*)kae|etc/passwd|eval\(|self/environ)" { deny all; }
location ~* "\.(aspx?|bash|bak?|cfg|cgi|dll|exe|git|hg|ini|jsp|log|mdb|out|sql|svn|swp|tar|rdf)$" { deny all; }
location ~* "/(^$|mobiquo|phpinfo|shell|sqlpatch|thumb|thumb_editor|thumbopen|timthumb|webshell)\.php" { deny all; }


https://gist.github.com/VirtuBox/5fedc39c30813f5373aa8ae9328a0ec3

Tuesday, May 9, 2017

Debian 8 Jessie Sample Preseed

#### Contents of the preconfiguration file (for jessie)
### Localization
d-i debian-installer/locale string en_US.UTF-8
d-i debian-installer/keymap select us
#d-i keymap select us
d-i keyboard-configuration/xkb-keymap select us

# Scan another CD or DVD?
apt-cdrom-setup apt-setup/cdrom/set-first       boolean false

### Network configuration
d-i netcfg/choose_interface select auto
# Manual
#d-i netcfg/get_nameservers  string 192.168.1.5
#d-i netcfg/get_ipaddress    string 192.168.1.10
#d-i netcfg/get_netmask      string 255.255.255.0
#d-i netcfg/get_gateway      string 192.168.1.1
#d-i netcfg/confirm_static   boolean true
#d-i netcfg/get_hostname string localhost
#d-i netcfg/get_domain string localdomain.com
#d-i netcfg/hostname string localhost

### Mirror settings
d-i apt-setup/use_mirror boolean true
d-i mirror/protocol string http
d-i mirror/country string manual
d-i mirror/http/hostname string debian.xtdv.net
d-i mirror/http/directory string /debian
d-i mirror/suite string jessie
d-i mirror/http/proxy string


### Account setup
d-i passwd/root-login boolean false
d-i passwd/make-user boolean true
d-i passwd/user-fullname string John
d-i passwd/username string john
d-i passwd/user-password-crypted password $6$pp9kuTEa$4rIwzjBHUK0jyRC1vE73k7EdQWu8azUCPkwHNOf1BCcV9AC74RVMiGGxKgwn4nxL2GIGSh5orkA8qirDjkJTI1
d-i passwd/user-uid string 1000
d-i passwd/user-default-groups string sudo adm

### Clock and time zone setup
d-i clock-setup/utc boolean true
d-i time/zone string Asia/Ho_Chi_Minh
d-i clock-setup/ntp boolean true

### Partitioning
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string lvm
d-i partman-auto/purge_lvm_from_device  boolean true
d-i partman-auto/choose_recipe select boot-root
d-i partman-auto-lvm/new_vg_name string system
d-i partman-auto/expert_recipe string                   \
        boot-root ::                                    \
        103 100 205 ext4                                \
                $primary{ }                             \
                $bootable{ }                            \
                method{ format } format{ }              \
                use_filesystem{ } filesystem{ ext4 }    \
                mountpoint{ /boot }                     \
        .                                               \
        1024 110 2048 ext4                              \
                $lvmok{ }                               \
                method{ format } format{ }              \
                use_filesystem{ } filesystem{ ext4 }    \
                mountpoint{ / }                         \
        .                                               \
        1024 120 3096 ext4                              \
                $lvmok{ }                               \
                method{ format } format{ }              \
                use_filesystem{ } filesystem{ ext4 }    \
                mountpoint{ /var }                      \
        .                                               \
        512 130 1024 ext4                               \
                $lvmok{ }                               \
                method{ format } format{ }              \
                use_filesystem{ } filesystem{ ext4 }    \
                mountpoint{ /var/lib/mysql }            \
        .                                               \
        512 140 1024 ext4                               \
                $lvmok{ }                               \
                method{ format } format{ }              \
                use_filesystem{ } filesystem{ ext4 }    \
                mountpoint{ /www }                      \
        .                                               \
        512 150 1024 ext4                               \
                $lvmok{ }                               \
                method{ format } format{ }              \
                use_filesystem{ } filesystem{ xfs }     \
                mountpoint{ /tmp }                      \
        .                                               \
        2048 160 3096 ext4                              \
                $lvmok{ }                               \
                method{ format } format{ }              \
                use_filesystem{ } filesystem{ ext4 }    \
                mountpoint{ /usr }                      \
        .                                               \
        512 170 1024 linux-swap                         \
                $lvmok{ }                               \
                method{ swap } format{ }                \
        .                                               \
        2048 10 3096 ext4                               \
                $lvmok{ }                               \
                method{ format } format{ }              \
                use_filesystem{ } filesystem{ xfs }     \
                mountpoint{ /home }                     \
        .
d-i partman/confirm boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-lvm/device_remove_lvm boolean true
#d-i partman-lvm/confirm boolean true
d-i partman/choose_partition \
        select Finish partitioning and write changes to disk
d-i partman/confirm_nooverwrite boolean true
d-i partman/mount_style select uuid
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
#d-i grub-pc/install_devices multiselect /dev/sda
d-i grub-installer/bootdev  string /dev/sda

### Apt setup
d-i apt-setup/non-free boolean true
d-i apt-setup/contrib boolean true
d-i apt-setup/services-select multiselect security, updates
d-i apt-setup/security_host string security.debian.org

# Dotdeb
#d-i apt-setup/local0/repository string http://packages.dotdeb.org wheezy all
#d-i apt-setup/local0/comment string Dotdeb
#d-i apt-setup/local0/source boolean true
#d-i apt-setup/local0/key string http://www.dotdeb.org/dotdeb.gpg

#d-i apt-setup/local1/repository string http://packages.dotdeb.org wheezy-php55 all
#d-i apt-setup/local1/comment string Dotdeb-PHP55
#d-i apt-setup/local1/source boolean true
#d-i apt-setup/local1/key string http://www.dotdeb.org/dotdeb.gpg

# Puppet
#d-i apt-setup/local2/repository string http://apt.puppetlabs.com wheezy main
#d-i apt-setup/local2/comment string Puppet
#d-i apt-setup/local2/source boolean true
#d-i apt-setup/local2/key string http://apt.puppetlabs.com/keyring.gpg

#d-i apt-setup/local2/repository string http://apt.puppetlabs.com wheezy dependencies
#d-i apt-setup/local2/comment string Puppet-Dependencies
#d-i apt-setup/local2/source boolean true
#d-i apt-setup/local2/key string http://apt.puppetlabs.com/keyring.gpg

### Package selection
tasksel tasksel/first multiselect none
d-i pkgsel/include string openssh-server curl
d-i pkgsel/upgrade select none
popularity-contest popularity-contest/participate boolean false

### Misc options
# Disable that annoying WEP key dialog.
#d-i netcfg/wireless_wep string
# Allow non-free firmware
d-i hw-detect/load_firmware boolean true
# Avoid that last message about the install being complete.
d-i finish-install/reboot_in_progress note

### Set up firstboot
#d-i preseed/late_command string chroot /target sh -c "/usr/bin/curl -o /tmp/postinstall http://vtm-svn-01.luxoft.com/postinstall && /bin/sh -x /tmp/postinstall"

Tuesday, April 25, 2017

Convert Ubuntu Desktop to Server

# update
sudo apt-get update

# install the 'tasksel' package so we can remove the desktop image       
sudo apt-get install tasksel

# remove the desktop image
sudo tasksel remove ubuntu-desktop

# tell tasksel to start the server image setup
sudo tasksel install server

# install the server images
sudo apt-get install linux-server linux-image-server

# remove lightdm
sudo apt-get purge lightdm

# remove all packages no longer required (~400 MB)
sudo apt-get autoremove

Monday, April 17, 2017

Upgrade Ubuntu 16.04 to 16.10 command line

First, SSH into your Ubuntu 16.04 server and upgrade all software.
$sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade

Then make sure you have update-manager-core package installed.
$sudo apt-get install update-manager-core

Next, edit a configuration file.
$sudo nano /etc/update-manager/release-upgrades
At the bottom of this file, change the value of Prompt from lts to normal.
Prompt=normal
Save and close the file. After that, run the following command to begin the upgrade process and follow the on-screen instructions.
$do-release-upgrade -d

Once the upgrade is finished, reboot your Ubuntu server. To check your Ubuntu version, run:
$lsb_release -a

Tuesday, April 4, 2017

Install Sky on Linuxmint 18.1

In able to use Lync in Linux, Sky will be good option. This installation for Linuxmint 18.1
  • Go to https://tel.red/repos.htm
  • Repo for Linuxtmint 18.1 equal to Ubuntu 16.04
  • Copy "deb https://tel.red/repos/ubuntu xenial non-free" to /etc/apt/source.list
  • Download and register TEL.RED software signing public key
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 9454C19A66B920C83DDF696E07C8CCAFCE49F8C5
sudo apt-get update
sudo apt-get install sky

Wednesday, March 29, 2017

Outlook Stationery Fonts changing to Arial after closing Outlook

Go to Signatures, then "Personal Stationary" tab and change fonts. It was being defaulted to Arial from here which was somehow overriding the "Stationary and Fonts" selection.

Tuesday, March 28, 2017

How to Disable the Write Protection on Dell Windows 10 USB Recovery Sticks

The world is full of different kinds a people, but one thing that seems to bring us all together is that everyone wants to be able to write to their Dell USB recovery drive. I'm not yet convinced that this one little slice of common ground can end wars and dispel years of hatred, but the one thing I am sure of is that with just the slightest effort... we can all write to these things.

It's been a while, but finally we have a solution for the Dell Windows 10 recovery drives. This time Tom Weber posted the solution in the round 3 post. Thanks Tom. All I did below was take his solution and add some screen clips. All the credit should go to him.

As of the time of this post, this works for all Dell Windows 10 USB recovery flash drives.

Download MPALL_F1_7F00_DL07_v503_0A.rar from Mega.nz and uncompress it to a folder. The Mega.nz decryption key is !3mpx__atjBu-zBVtxTlvsya-uiIsSFK7q5ddcULiCgw and the MD5 hash of the file is E37A0C352EFF3415E7DB2E6A6CF7F5EB. With this hash you should be able to verify that the file you downloaded is exactly the same as the file I uploaded. I can't guarantee anything else about this file. Use it at your own risk.

Caution! The following steps WILL DELETE EVERYTHING ON THE USB DRIVE!