Search This Blog

Showing posts with label arsenal. Show all posts
Showing posts with label arsenal. Show all posts

Tuesday, June 6, 2023

Ubuntu Port Firewall uwf - not via iptables

 step 1: apt install ufw

step 2: ufw enable

step 3:   sudo nano /etc/default/ufw

          #enable ipv6=yes

step 4: Added default deny of incoming and allow outgoing

   sudo ufw default deny incoming

   sudo ufw default allow outgoing


#. to see the list   

sudo ufw app list


step 5: #. Allow open ssh for all your login and other operations

sudo ufw allow OpenSSH

   sudo ufw allow ssh

   sudo ufw allow 22

   sudo ufw show added

   sudo ufw enable


step 6: #. Allow default web ports and custom ports

   sudo ufw allow http

   sudo ufw allow https

   sudo ufw allow 8099

   sudo ufw allow 88


 

#. To see the port list

   sudo ufw status verbose


#. To deny the ports

   sudo ufw deny <port>


Thank You

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-ubuntu-18-04



Wednesday, May 31, 2023

Linux Ubuntu - See Running process with port number and details for that service

To see the pid details of running process

step 1.

lsof -i TCP:<port number>


lsof -i TCP:99


step 2

ps -ef | grep <pid>

ps -ef | grep 39100


step 3

kill -9 <pid>

Wednesday, December 14, 2022

Wednesday, June 30, 2021

Python - Image to Pdf

1. Install img2pdf

> pip/pip3 install img2pdf

2. img2pdfown.py


# importing necessary libraries

import img2pdf

from PIL import Image

import os

  

# CLI  img2pdf *jpg -o output_all_pngs.pdf

'''

img_path = "image1.jpg";

pdf_path = "output.pdf";

image = Image.open(img_path);

pdf_bytes = img2pdf.convert(image.filename);

file = open(pdf_path, "wb");

file.write(pdf_bytes);

image.close();

file.close();

'''


# convert all files ending in .jpg inside a directory

dirname = "dump/images/"

imgs = []

#dpix = dpiy = 300;

#layout_fun = img2pdf.get_fixed_dpi_layout_fun((dpix, dpiy))

for fname in os.listdir(dirname):

    if not fname.endswith(".jpg"):

        continue

    path = os.path.join(dirname, fname)

    if os.path.isdir(path):

        continue

    imgs.append(path)

    print ("\n" + path);

with open("dump/output.pdf", "wb") as f:

    #f.write(img2pdf.convert(imgs, layout_fun=layout_fun));

    f.write(img2pdf.convert(imgs));

  

'''    

imgs = ['dump/images/page_1.jpg', 'dump/images/page_2.jpg', 'dump/images/page_10.jpg']

with open("dump/output1.pdf", "wb") as f:

    f.write(img2pdf.convert(imgs))


# specify paper size (A4)

a4inpt = (img2pdf.mm_to_pt(210), img2pdf.mm_to_pt(297))

layout_fun = img2pdf.get_layout_fun(a4inpt)

with open("name.pdf", "wb") as f:

    f.write(img2pdf.convert('test.jpg', layout_fun=layout_fun))


# use a fixed dpi of 300 instead of reading it from the image

dpix = dpiy = 300;

layout_fun = img2pdf.get_fixed_dpi_layout_fun((dpix, dpiy))

with open("name.pdf", "wb") as f:

    f.write(img2pdf.convert('test.jpg', layout_fun=layout_fun))


# create a PDF/A-1b compliant document by passing an ICC profile

with open("name.pdf", "wb") as f:

    f.write(img2pdf.convert('test.jpg', pdfa="/usr/share/color/icc/sRGB.icc"))    

'''

    


Friday, May 28, 2021

Eclipse - boto3 botocore.exceptions.ProfileNotFound: The config profile () could not be found

1.  If terminal is not opening, 

Go and update the eclipse from Help->MarketPlace.

2. See whether you installed boto3 and awscli from sudo or root and now you login as same user or different, 

   if different, then uninstall the above two plugin and install with the current user. 

    pip/pip3 install boto3

    pip/pip3 install awscli


3.type aws configure

            Enter Key, access scret, region

4. type vi ~/.aws/credentials

        [default]

            aws_access_key_id = xxx

            aws_secret_access_key = xx+xx

        [vijay]

            aws_access_key_id = x

            aws_secret_access_key = x+xx


5. your python program
   
          import csv
import datetime
import os
import smtplib, ssl
import boto3

botSession=boto3.session.Session(profile_name="vijay")
iam_mag_con=botSession.client(service_name="ec2",region_name='us-east-2')
resp = iam_mag_con.describe_regions()

....... 

Monday, June 8, 2020

Python Array of Array - Inner Array processing

#Program -1, To print array of array 
 
a = [[{'Key': 'key700', 'Value': 'val145'}, {'Key': 'key123', 'Value': 'val123'}]]

for i in range(len(a)):
    for j in range(len(a[i])):
        jsonData = a[i][j]
        #print(jsonData);
        for (k, v) in jsonData.items():
            print("Key: " + k)
            print("Value: " + str(v))

   


'''
output
********
Key: Key
Value: key700
Key: Value
Value: val145
Key: Key
Value: Key123
Key: Value
Value: val123

'''


#Program -2 , print only the key=userName

import json

a = [[{'Key': 'age', 'Value': '10'}, {'Key': 'userName', 'Value': 'vijay'}, {'Key': 'address', 'Value': '1, car st'}, {'Key': 'userName', 'Value': 'pranika'}]]

for i in range(len(a)):
    for j in range(len(a[i])):
        jsonData = a[i][j]
        data = json.loads(json.dumps(jsonData ) );
        if ( jsonData['Key'] == 'Name' ):
            print ( jsonData['Value'] )

           
       
   


'''
output
********
vijay
pranika
'''

 

Tuesday, June 2, 2020

Postgresql 12 with PGAdmin4 Installation in Linux Ubuntu 16 18 20


 Install Postgresql 12

1. sudo apt-get install postgresql-12

2.  sudo -u postgres psql postgres

3. \password postgres

         Enter new and confirm password : xxxxx



Install PGAdmin 4


1. apt clean

2. apt autoclean

3. sudo apt update

4. sudo apt install pgadmin4 pgadmin4-apache2
                   #. username : postgres@localhost
                   #. pwd : xxxxx

5. sudo ufw allow http

6. sudo ufw allow https


7. In Browser : http://localhost/pgadmin4/

8. 4th point credentials

9. Type again http://localhost/pgadmin4/browser/ if you see apache2 default page.

10. Connect with new server -> Postgres user/pwd.



Thursday, May 28, 2020

Linux Ubuntu Change Complexity Length & Strong Password

vim /etc/pam.d/common-password


#Remove obscure word and add minlen=1


password    [success=1 default=ignore]  pam_unix.so minlen=1 sha512
 

Ubuntu Disable Each time Password Entering

sudo nano -w /etc/sudoers
 
 
Replace 

%sudo  ALL=(ALL) ALL 
  
TO

%sudo  ALL=(ALL) NOPASSWD:ALL
 
 
 
- Enjoy
 

Wednesday, February 26, 2020

AttributeError: module 'pytesseract' has no attribute 'image_to_string'

may be your python file name itself "pytesseract,py"

kindly rename it to new name like pytes_ex.py.


--Enjoy

Hit Counter


View My Stats