Skip to content

Category: english

find a process running a deleted library

sudo find /proc -maxdepth 2 -name maps -exec grep -HE ‘\(deleted\)’ {} \; | cut -d/ -f3 | sort -u | xargs –no-run-if-empty ps

Looking for libssl in specific:

sudo find /proc -maxdepth 2 -name maps -exec grep -HE ‘/libssl\.so.* \(deleted\)’ {} \; | cut -d/ -f3 | sort -u | xargs –no-run-if-empty ps

Killing all process using a deleted version of libssl:

sudo find /proc -maxdepth 2 -name maps -exec grep -HE ‘/libssl\.so.* \(deleted\)’ {} \;| cut -d/ -f3 | sort -u | xargs –no-run-if-empty sudo kill

heredoc to feed an interactive program

Let this interactive.sh be the interactive program:
[bash]#!/bin/sh
read input1
read input2
echo $input1 $input2
[/bash]

This is a script feed.sh (in the same directoty) that uses heredoc to feed two lines to interactive.sh:
[bash]#!/bin/sh
./interactive.sh << EOF
asdf
zxcv
EOF
[/bash]

It work as:
[bash]$ ./feed.sh
asdf zxcv
[/bash]

“and I know too well that these arguments from probabilities are impostors, and unless great caution is observed in the use of them they are apt to be deceptive-in geometry, and in other things too” Socrates, in Phaedo by Plato. 399 BC.

Jeep Wrangler ASCII Art Collection

Some ASCII/ANSI/Shift_JIS/Unicode art of Jeep Wranglers. They are easy to modify and introduce your own customizations.

These I found on the web:

  __________ 
 |          | 
 |______(*)_| 
 /\__----__/\ 
/_/()||||()\_\ 
|_\ o||||o /_| 
|----Jeep----| 
|_|        |_| 


                   _.------------------.
                 .'____________________|
                 //    _||||  | |  | | |
          ______//_\__j_|||"--" "--" | |  _
         /-----+-|p  ==,|||__________|_|-|W|
        _j,====. |b_____|||  _____     | |W|
       |_) ,---.`.`------'|.',---.`.___|_|W|
         `/ .-. \\`======__// .-. \`-----'""
          \ `-' / """""""   \ `-' /
           `---'             `---'     hjw

  ____        
 /_/CL\___     
 \_,.__,._)    
---`'--`'--MK  
  ____
 |_| L\___
 |_,.__,._)
---`'--`'--MK

/l ,[____],
l---L -O||||||O-
()_)-()_)-o-)_)

    ______ooooo
  /__|_|_,\____\,___
  |_---|_|__|---O|||O
_.(o)_)__(o)_)--o-)_) 

               ∩_∩
        // ̄ヽ_( ・(ェ)・)  ____
       | ̄ ̄|_ (⊃/ ̄ ̄ ̄(O|||||O)
 .⌒ヽ ,;;; | / ̄ヽ ||___|// ̄ヽ ̄| |||||/ヽ
 (";"':;.):;゙ |_| ◎ |___ | ◎ .| |=======
   ⌒;:ヽ;; ヽ_//     ヽ_// ヽ_//
~~~~´゙`゙゙´´ ~~~~゙`゙´``´゙`゙゙´´ ~~゙゙´``´`´ ~~~


,[____l,
_-o||||o-_
()_)¯¯ )_)

O|||||||O

•IIIIII•

This one I created:

 
 â—„
  ╽██████████████       
  ▓█ ██ █✌ຈل͜ຈ █▄▄▄▄▄
  ▓█████████████⚪║║║║⚪█ 
  ═█▓▓██████▓▓▀████ºº███▀
    â–“â–“ â–“â–“   â–“â–“       â–“â–“

This one is a remix of one from hjw (Hayley Jane Wakenshaw) with an extra door, i.e. the Jeep Wrangler Unlimited.


                   _.---------------------.
                 .'_______________________|
                 //    _|||    || |   | | |
          ______//_\__j_|||____|| "---" | |  _
         /-----+-|p  ==,|||p ==,|_______|_|-|W|
        _j,====. |b_____|||b    /_____    | |W|
       |_) ,---.`.`------'|----.',---.`.__|_|W|
         `/ .-. \\`======__====// .-. \`---'""
          \ `-' / """""""  """" \ `-' /
           `---'                 `---'  

A remix of this post from @TwitAA_bot:

  __________ ⌒彡
 |          |冫、)
 |__________|` /
 /\__----__/\ /
/_/()||||()\_\
|_\ o||||o /_|
|------------|
|_|        |_|

Sources:

if host pings execute command

[bash]#!/bin/sh
HOST="silveiraneto.net"
if ping -c 1 $HOST > /dev/null
then
echo your command
fi
[/bash]

  • replace silveiraneto.net for your desired hostname or ip
  • ping sends only one package (-c 1) and ignores the text output
  • a ping is successful returns 0 and the if proceeds
  • replace the echo line with your command

printing only odd or even lines using sed

$ cat AtoF
A
B
C
D
E
F

Print only odd lines

sed -n 'p;n' AtoF
A
C
E

-n suppress automatic printing of pattern space, p print the current pattern space, n read/append the next line of input into the pattern space.

Alternatively:

$ sed -n 1~2p AtoF
A
C
E

-n suppress automatic printing of pattern space, 1~2 from the 1st line match every line every 2 steps, p print the current pattern space. sed -n 0~p has the same effect . print only the even lines.

Print only even lines

$ sed -n 'n;p' AtoF 
B
D
F

or

$ sed -n 2~2p AtoF
B
D
F

0~2p would also work. I prefer

PNG to PDF and PNG to PDF

You can use ImageMagick to convert multiple PNGs into a PDF and convert a multiple pages PDF into multiple PNGs.

PDF to PNG

$ convert document.pdf document.png

For a document with 10 pages, this will generate document-0.png, document-1.png, … document-9.png.

PNG to PDF

$ convert document*.png document.pdf

This convert the PNG pages into pages in the document.pdf document.

One-time pad using GIMP

With a ∈ {0,1} and b ∈ {0,1}, the XOR function {0,1}→{0,1} can be defined by the truth table:

a b a XOR b
0 0 0
0 1 1
1 0 1
1 1 0

Gimp doesn’t have a layer operation called XOR but there is the “Difference” mode defined by the Gimp User Manual by the equation:

$latex E =|I – M|$

Applying the formula to the Red Green Blue color mode for a pixel we have:

$latex rgb(|r_I-r_M|,|g_I-g_M|,|b_I-b_M|) =|rgb(r_I,g_I,b_I) – rgb(r_M,g_M,b_M)|$

The truth table for the “difference” mode is:

I M |I – M|
rgb(0,0,0) rgb(0,0,0) rgb(0,0,0)
rgb(0,0,0) rgb(255,255,255) rgb(255,255,255)
rgb(255,255,255) rgb(0,0,0) rgb(255,255,255)
rgb(255,255,255) rgb(255,255,255) rgb(0,0,0)

Let’s call black-white representation this binary pallet:

  • the white color, i.e. rgb(255,255,255), represent the number 1
  • the black color, i.e. rgb(0,0,0), represent the number 0.

Then the truth table for the difference is the same as the XOR one.

Experimenting with images

Let A_0101.png be this image:
A_0101.png

And B_0011.png be this image:
B_0011

Notice that each image use the black-white representation of the binary message in the file name.

After we apply the “Difference” layer mode with the two images we have what we can call AXORB_0110.png:

A XOR B 0110

One-time pad

Let message.png be this 512×512 image using a 1-bit pallet (Lena with Floyd–Steinberg dithering):

Lena Soderberg

And key.png a image of the same size and pallet with random content:
key

We can create a image messageXORkey.png using the Gimp’s different mode:

messageXORkey

The messageXORkey.png looks as random as the key or any other random key.

Someone in possession of messageXORkey.png and key.png can apply a XOR to retrieve message.png. That’s because:

messageXORkey.png = message.png XOR key.png
messageXORkey.png XOR key.png = message.png XOR key.png XOR key.png
messageXORkey.png XOR key.png = message.png XOR 0
messageXORkey.png XOR key.png = message.png

Considerations

This was a demonstration of how to use GIMP to encode and decode one-time pads. There are several constraints to use one-time pads in a secure way for practical purposes that you should know before using it in a real situation.