Category: Linux

Apache, Linux, MySQL, PHP, Ubuntu Server

Install LAMP stack on Ubuntu 16.04

Update system sudo apt-get update && sudo apt-get dist-upgradesudo apt-get update && sudo apt-get dist-upgrade Install Apache sudo apt-get install apache2sudo apt-get install apache2 Install MySQL sudo apt-get install mysql-serversudo apt-get install mysql-server Install PHP sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql php-mbstring php-gettextsudo apt-get install php libapache2-mod-php php-mcrypt php-mysql php-mbstring php-gettext Install PHPMyAdmin sudo …

Linux

Move directory to another server

* Compress directory tar cvzf myfolder.tar.gz myfolder/tar cvzf myfolder.tar.gz myfolder/ * Copy directory scp myfolder.tar.gz [username]@[ip_address_or_hostname]:/home/[username]/myfolder.tar.gzscp myfolder.tar.gz [username]@[ip_address_or_hostname]:/home/[username]/myfolder.tar.gz * Extract directory contents on new server tar -xvzf myfolder.tar.gz -C /path/to/myfoldertar -xvzf myfolder.tar.gz -C /path/to/myfolder

Linux

Change Ubuntu server from DHCP to a static IP address

1. Open interfaces file for editing: sudo nano / etc/network/interfacessudo nano / etc/network/interfaces 2. Change interfaces file contents to: auto eth0 iface eth0 inet static address 192.168.10.15 netmask 255.255.255.0 network 192.168.10.0 gateway 192.168.10.1 dns-nameservers 192.168.10.1 8.8.8.8auto eth0 iface eth0 inet static address 192.168.10.15 netmask 255.255.255.0 network 192.168.10.0 gateway 192.168.10.1 dns-nameservers 192.168.10.1 8.8.8.8 You will have …

Linux

Quick FTP Server Installation

Installation sudo apt-get install vsftpdsudo apt-get install vsftpd Upload files By default vsftpd is configured to authenticate system users and allow them to download files. If you want users to be able to upload files, edit configuration file: sudo nano / etc/vsftpd.confsudo nano / etc/vsftpd.conf write_enable=YES Restart vsftpd sudo service vsftpd restartsudo service vsftpd restart …

C, Drivers, Linux, Rootkits

Hello World Linux Module

Hello World Module #include <linux/init.h> #include <linux/module.h>   static int init_module(void) { printk(KERN_ALERT "Hello, world!n"); return 0; }   static void clean_module() { printk(KERN_ALERT "Goodbye, world!n"); }#include <linux/init.h> #include <linux/module.h> static int init_module(void) { printk(KERN_ALERT "Hello, world!n"); return 0; } static void clean_module() { printk(KERN_ALERT "Goodbye, world!n"); } Compile – Makefile ifneq ($(KERNELRELEASE),) obj-m := …

Linux, Python

Simple python sniffer with pcapy and impacket

Pcapy home page Impacket home page To install pcapy and impacket: sudo apt-get install python-pcapysudo apt-get install python-pcapy sudo apt-get install python-impacketsudo apt-get install python-impacket Run the script below with root privileges. #!/usr/bin/python   import pcapy import sys from impacket import ImpactDecoder   def callback(header, data): decoder = ImpactDecoder.EthDecoder() ethernet_pck = decoder.decode(data) ip_hdr = ethernet_pck.child() …

Linux, Python

SSH authentication with Python and paramiko

paramiko home page SSH2 protocol for python.   import os import paramiko import sys   try: ssh = paramiko.SSHClient() paramiko.util.log_to_file("./errors.log") ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.load_host_keys(os.path.expanduser(os.path.join("~", ".ssh", "known_hosts"))) ssh.connect(’myserver.com’, username=’user_name’, password=’pass_word’) ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command(’ls /home/username/’) print "outputn", ssh_stdout.read() error = ssh_stderr.read() print "errorsn", error, len(error) except Exception, e: print "username or password is wrong or the server …

C++, Linux

Select from SqLite with C++ in Linux

If you are using Ubuntu Linux, you can install sqlite headers by issuing the following command: sudo apt-get install libsqlite3-devsudo apt-get install libsqlite3-dev The code: #include <iostream> #include <sqlite3.h> using namespace std;   static int print_results(void *notInUse, int argc, char **argv, char **colName) { int i; for(i=0; i<argc; i++) cout << colName[i] << " = …