21 August 2020

pip install package on previous version

 1- to list available package:

   pip install thepackage==randomwords

(attemp to install unexist package, will return error, and pip will display available package)



2- install certain version of package

   pip install libvirt-python==5.10.0

19 August 2020

Laravel - Redis - Que - Failed Job

 Laravel has capability to send task/job to worker. Means when the request coming from client/browser, certain task/code can be pass to be process later by worker. This will enable laravel to complete the http response faster, without need to wait for that certain code to finish process.


In laravel, this can be done by creating a class that implements ShoudQueue.

class ProcessPodcast implements ShouldQueue

ProcessPodcast::dispatch()   will tell Laravel to queue the job in redis(this is one of the option), then worker will retrieve the job from redis.

If there is error during the job execution, it will be put in table failed_jobs.

We can request Laravel to resubmit this fail jobs to redis again by:
php artisan queue:retry all


To check jobs list in redis:

$ redis-cli
127.0.0.1:6379> keys *
From figure above, we can tell the pending jobs in redis is 131,093.



To check failed jobs:
mysql> select (*) from failed_jobs;






17 August 2020

Domain Fronting Attack

As want to connect to www.google.co.uk, instead connect to www.google.com.au

$ curl -H "host: www.google.com.au" www.google.co.uk



Fakely connect to baik.com, but actually connect to jahat.com, This can be done if baik.com use same CDN as jahat.com

$ curl -H "host: jahat.com" https://baik.com

11 August 2020

Using custom CA in python virtual environment

 You have installed your custom CA in your client machine. Using curl, everthing is fine(refer here).

But since your python script  use  virtenv, your script cannot see the custom CA.



This is because python virtualenv looking the certifcates in different place than the normal python 

$ python -c "import requests; print ( requests.certs.where() )"
/etc/ssl/certs/ca-certificates.crt

$ (.venv) python -c "import requests; print (requests.certs.where())" 
.../.venv/lib/python3.6/site-packages/certifi-2020.6.20-py3.6.egg/certifi/cacert.pem


Solution, is to import the custom CA to the virtual Environtment.

openssl x509 -in $specific_ca.crt -text >> $virtualenv/lib/python3.6/site-packages/certifi-2020.6.20-py3.6.egg/certifi/cacert.pem



ref:

https://stackoverflow.com/questions/34931378/certificate-verification-when-using-virtual-environments

06 August 2020

Add custom CA to ubuntu

tested with ubuntu 18:04


1) sudo apt-get install ca-certificates



2) copy CA certificate to local:
      sudo cp CERTIFICATE.crt /usr/local/share/ca-certificates/


If your certificate in PEM format, need to convert to .crt using this command:
openssl x509 -outform der -in CERTIFICATE.pem -out CERTIFICATE.crt

3) update certificate
  sudo update-ca-certificates



ref:  


28 July 2020

LVM, add new partition to extend lv(logical volume)

Concept:

- has 3 logical layer
-- pv(physical volume)
       partition to be use for LVM
-- gv(group volume)
       group of partition(pv) seen as 1 big harddisk. One system/OS could have multiple gv
-- lv(logical volume)
       lv to gv, is as partition to harddisk




To extend partition(lvm), by adding new partition to be part of the lvm

1- create partition on new drive
     

2- register the partition as pv
      pvcreate /dev/sdb1
      pvdisplay



3- add the pv  to be a member of on of the gv
       use vgdisplay to check name existing volume group(vg)

       vgextend _name_of_volume_group_ /dev/sdb1



4-  extend the current lvm to utilize the free space in gv
       lvm to gv is as a partition to harddisk. At this stage, our gv size has increase. So we have oppurtunity to increase size of the lvm base on free size on the gv.

       use lvdisplay to check LV_path

      lvextend -l +100%FREE __LV_path__
        or
       lvextend -L +100G __LV_path__



5- extend filesystem
       resize2fs /dev/mapper/__LV_Name__





ref:
1- https://www.krenger.ch/blog/linux-lvm-how-to-adding-a-new-partition/