Soluții

Windows Security Troubleshooter

Acesta este un instrument de depanare de la Windows, dar va trebui să îl descărcați separat de pe site-ul Microsoft. Instrumentul de depanare de securitate Windows scanează computerul și se asigură că toate caracteristicile de securitate sunt activate și funcționează conform intenției. Dacă credeți că setările de securitate ale computerului dvs. sunt incorecte sau nu sunt actualizate, acest instrument le va remedia automat.

[mai mult...]

How to install aws cli on Linux

The AWS CLI is an essential tool for developers and sysadmin to automate and interact with AWS cloud services. It is an open-source tool built on the AWS SDL for Python. As a result, you no longer need to use AWS Management Console. Instead, you can use Linux terminal and commands for managing AWS resources.

Installing AWS cli on Linux
  1. Open the terminal application.
  2. Then type command as per your Linux distro to install aws cli kit:
    1. Debian/Ubuntu Linux user, type:sudo apt install awscli
    2. Fedora Linux user, type:sudo dnf install awscli
    3. RHEL/CentOS/Rokcy/Alma Linux user, type (first, turn on ELEP repo and then):sudo dnf install awscli
    4. Alpine Linux user, type:apk add aws-cli
    5. Arch Linux user, type:sudo pacman -S aws-cli
    6. OpenSUSE/SUSE Linux user, type:sudo zypper in aws-cli
    7. Install AWS CLI version 1.x using PIP generic method:python3 -m pip install awscliDo you want AWS cli version 2? Try:python3 -m pip install awscliv2
      ~/.local/bin/awscliv2 --install
      Make sure you include ~/.local/bin/ in your $PATH. For example, here is how to set up PATH on your Linux:# Step #1. Set PATH variable #
      echo 'export PATH=$PATH:~/.local/bin' >>~/.bashrc
      # Step #2. Set bash alias too #
      echo 'alias aws="awsv2"' >>~/.bashrc
      # Step #3. Use the source command to load changes #
      source ~/.bashrc
  3. Once installed, find out AWS CLI version, run:aws --versionDepending upon your package manager and Linux distro, you may get the latest or older version. For instance, here is the output from my Ubuntu 20.04 LTS developer workstation:
    aws-cli/1.18.69 Python/3.8.10 Linux/5.13.0-35-generic botocore/1.16.19

    Here is outputs from v2:

    2.1.1
    AWS CLI v2 command: /home/ubuntu/.awscliv2/binaries/aws
    aws-cli/2.4.28 Python/3.8.8 Linux/5.13.0-37-generic exe/x86_64.ubuntu.22 prompt/off
  4. Next, you need to configure AWS cli with API keys. Log in to the AWS management console and grab API access keys if you don’t have any. Then configure it as follows:aws configure
  5. So far, you have installed AWS cli. Then configured access, and now it is time to test it. First, I will run the ‘aws s3 ls’ command to list your aws s3 resources:aws s3 ls
    Here is what I see when everything is configured correctly:

    2016-07-25 16:11:06 xyz-project-freenas
    2020-07-03 13:55:47 xyz-project-forum
    ....
    ..
A note about credentials file

Your aws CLI credentials are stored in plain text inside ~/.aws/ directory. Therefore, do not share ~/.aws/ directory and files. You can view it using the cat command:
cat ~/.aws/credentials
It is possible to store credentials in an encrypted format. The other option is to use and enable AWS Multi-Factor Authentication (MFA). It is a best practice that adds an extra layer of protection for your credentials.

[mai mult...]

How to convert JSON to CSV using Linux / Unix shell

What are JSON and CSV formats?

JSON is an acronym for JavaScript Object Notation. Often used in web apps, but it is not limited to JavaScript. One can use any programming language such as Perl, Python or CLI tools such as jq. CSV is an acronym for Comma-separated values. It is a text file you can use in spreadsheet apps, programming languages and many other apps.

Example of JSON format

Here the outputs of the df command in JSON format:

[
  {
    "fs": "/dev/mapper/vgubuntu-root",
    "type": "ext4",
    "size": "915G",
    "used": "135G",
    "avail": "734G",
    "usedpercentage": "16%",
    "mounted": "/"
  },
  {
    "fs": "/dev/nvme0n1p2",
    "type": "ext4",
    "size": "1.4G",
    "used": "378M",
    "avail": "939M",
    "usedpercentage": "29%",
    "mounted": "/boot"
  },
  {
    "fs": "/dev/nvme0n1p1",
    "type": "vfat",
    "size": "511M",
    "used": "30M",
    "avail": "482M",
    "usedpercentage": "6%",
    "mounted": "/boot/efi"
  }
]
Example of CSV format

The JSON outputs in CSV format (all values are separated by a comma , value):

/dev/mapper/vgubuntu-root,ext4,915G,135G,734G,16%,/
/dev/nvme0n1p2,ext4,1.4G,378M,939M,29%,/boot
/dev/nvme0n1p1,vfat,511M,30M,482M,6%,/boot/efi
Converting JSON to CSV using Linux / Unix shell

So how do you convert such input? The answer is to use jq or dasel command-line utilities.

Installing jq

Since jq is available in most common repos, I will use that one for my needs. Here is how to install jq on a Debian or Ubuntu Linux using the apt command/apt-get command:
sudo apt install jq
RHEL/Fedora/CentOS/Alma/Rocky Linux user try the dnf command:
sudo dnf install jq
Alpine Linux user try the apk command:
sudo apk add jq
SUSE or OpenSUSE Linux user try the zypper command:
sudo zypper in jq
macOS / OS X user install homebrew and then use the brew command:
brew install jq

Example – convert JSON to CSV under Linux

The syntax is as for df.json:
cat df.json | jq
Now let us extract the fs field, run:
cat df.json | jq '.[] | .fs'
How about both fs and type fields?
cat df.json | jq '.[] | .fs, .type'

To generate CSV file with , as separator use the following syntax:
cat df.json | jq '.[]| join(",")'
The join(",") joins the array of elements given as input, using the argument , as separator:

"/dev/mapper/vgubuntu-root,ext4,915G,135G,734G,16%,/"
"/dev/nvme0n1p2,ext4,1.4G,378M,939M,29%,/boot"
"/dev/nvme0n1p1,vfat,511M,30M,482M,6%,/boot/efi"

Pass the -r raw option to get rid of double quotes:
cat df.json | jq -r '.[]| join(",")'

How do I convert a JSON file to CSV?

Let us consider the following file displayed using the bat/cat commandcat bingbot.json
batcat bingbot.json

Sample config:

{
  "creationTime": "2021-11-10T10:00:00.121331",
  "prefixes": [
    {"ipv4Prefix": "157.55.39.0/24"},
    {"ipv4Prefix": "207.46.13.0/24"},
    {"ipv4Prefix": "40.77.167.0/24"},
    {"ipv4Prefix": "13.66.139.0/24"},
    {"ipv4Prefix": "13.66.144.0/24"},
    {"ipv4Prefix": "52.167.144.0/24"},
    {"ipv4Prefix": "13.67.10.16/28"},
    {"ipv4Prefix": "13.69.66.240/28"},
    {"ipv4Prefix": "13.71.172.224/28"},
    {"ipv4Prefix": "139.217.52.0/28"},
    {"ipv4Prefix": "191.233.204.224/28"},
    {"ipv4Prefix": "20.36.108.32/28"},
    {"ipv4Prefix": "20.43.120.16/28"},
    {"ipv4Prefix": "40.79.131.208/28"},
    {"ipv4Prefix": "40.79.186.176/28"},
    {"ipv4Prefix": "52.231.148.0/28"},
    {"ipv4Prefix": "51.8.235.176/28"},
    {"ipv4Prefix": "51.105.67.0/28"}
  ]
}

The final goal is to produce .CSV file as follows: for my WAF:

157.55.39.0/24,BingBot
207.46.13.0/24,BingBot
40.77.167.0/24,BingBot
13.66.139.0/24,BingBot
13.66.144.0/24,BingBot
52.167.144.0/24,BingBot
13.67.10.16/28,BingBot
13.69.66.240/28,BingBot
13.71.172.224/28,BingBot
139.217.52.0/28,BingBot
191.233.204.224/28,BingBot
20.36.108.32/28,BingBot
20.43.120.16/28,BingBot
40.79.131.208/28,BingBot
40.79.186.176/28,BingBot
52.231.148.0/28,BingBot
51.8.235.176/28,BingBot
51.105.67.0/28,BingBot

Commands

First type the following to get CIDR prefixes:
cat bingbot.json | jq '.prefixes[]'
Then pipe outputs to create new JSON to add a comment field:
cat bingbot.json | jq -r '.prefixes[] | {cidr: .ipv4Prefix, comment: "BingBot"}'
Finally, use the join() to make a .CSV file:
cat bingbot.json | jq -r '.prefixes[] | {cidr: .ipv4Prefix, comment: "BingBot"} | join(",")'
Save it:
cat bingbot.json | jq -r '.prefixes[] | {cidr: .ipv4Prefix, comment: "BingBot"} | join(",")' > bingbot.csv
Verify it:
cat bingbot.csv

[mai mult...]