Here is a simple code snippet that takes google service account .json file as input and gives you access token with the specified scope.
Hope it helps somebody who is in need of , or been searching for it.
28 March 2020
22 January 2020
Install latest linux kernel on Ubuntu server
Sometimes upgrading linux kernel may increase overall performance of your server (including network and task processing).
You can download any version of kernel from here
https://kernel.ubuntu.com/~kernel-ppa/mainline/
Latest Stable Kernel: 5.4.13 https://kernel.org
so we install kernel 5.4.13
if your Ubuntu version is old you may need to install additional dependency packages
You can search any missing packages here https://packages.ubuntu.com/search and get their download links and install using dpkg -i.deb
You can download any version of kernel from here
https://kernel.ubuntu.com/~kernel-ppa/mainline/
Latest Stable Kernel: 5.4.13 https://kernel.org
so we install kernel 5.4.13
cd /tmp/
wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.4.13/linux-headers-5.4.13-050413_5.4.13-050413.202001171431_all.deb
wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.4.13/linux-headers-5.4.13-050413-generic_5.4.13-050413.202001171431_amd64.deb
wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.4.13/linux-image-unsigned-5.4.13-050413-generic_5.4.13-050413.202001171431_amd64.deb
wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.4.13/linux-modules-5.4.13-050413-generic_5.4.13-050413.202001171431_amd64.deb
sudo dpkg -i *.deb
if your Ubuntu version is old you may need to install additional dependency packages
You can search any missing packages here https://packages.ubuntu.com/search and get their download links and install using dpkg -i
3 November 2019
Telegram bot file_id parser
function base64url_decode($data) { return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT)); } function rle_decode($string) { $new = ''; $last = ''; $null = chr(0); foreach (str_split($string) as $cur) { if ($last === $null) { $new .= str_repeat($last, ord($cur)); $last = ''; } else { $new .= $last; $last = $cur; } } $string = $new.$last; return $string; } function parse($s) { $s = base64url_decode($s); $s=rle_decode($s); $r=unpack("ifile_type/idc_id/qfile_id/qaccess_hash",$s); return $r; } var_dump(parse('AgADBAADZbMxG7cJAVGXAeNiLWOiH5lPqBsABAEAAwIAA3kAAzcYAwABFgQ'));
possbible file_type list
0 = thumbnail
2 = photo
3 = voice
4 = video
5 = document
8 = sticker
9 = audio
10 = gif
13 = video_note (round video)
Setup Network File System(NFS) Client and Server on Ubuntu
server side run the following commands.
apt install nfs-kernel-server
vi /etc/exports
add /path/you/want/to/share/with/client 10.0.0.0/16(rw,sync,no_root_squash,no_subtree_check)
save it
run exportfs -v
run exportfs -ra
client side commands
apt install nfs-common
mount -t nfs -o vers=3 10.0.0.4:/remote/path /local/path
for persistent mount, add entry in fstab.
vi /etc/fstab
10.0.0.4:/remote/path /local/path nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0
4 February 2019
TANGEDCO TNEB AE 2018 Results, Cut-off, Question papers and Answers
TANGEDCO TNEB AE 2018 exam which was conducted on 30/12/2018 its result was released today 04/02/2019 around 7pm-8pm.
i have collected question papers from their unstable website for all department with answers.
You can view or download questions and answer from google drive link https://drive.google.com/drive/folders/1cGjvM3tdMk0AaDKbS5fVTSVR9TC3Xx_B
Check your marks here https://drive.google.com/open?id=1i40-NM-Pt4TxJc7sW-wakJzpG3yLsK5M
Cutt-off marks https://drive.google.com/open?id=1rLtPFxX9UTL76pljY8ehs1Qp-H0AavM-
better luck next time.
i have collected question papers from their unstable website for all department with answers.
You can view or download questions and answer from google drive link https://drive.google.com/drive/folders/1cGjvM3tdMk0AaDKbS5fVTSVR9TC3Xx_B
Check your marks here https://drive.google.com/open?id=1i40-NM-Pt4TxJc7sW-wakJzpG3yLsK5M
Cutt-off marks https://drive.google.com/open?id=1rLtPFxX9UTL76pljY8ehs1Qp-H0AavM-
better luck next time.
8 September 2018
execute root commands via php
Solution using a binary wrapper (with suid bit)
1) Create a script (preferrably
.sh
) that contains what you want to be ran as root.# cat > php_shell.sh <<CONTENT
#!/bin/sh
/sbin/service sshd restart
CONTENT
2) This file should be owned by root, and since it will later run with root permissions make sure that only root has permission to write to the file.
# chown root php_shell.sh
# chmod u=rwx,go=xr php_shell.sh
3) To run the script as root no matter what user that executes it, we will need a binary wrapper. Create one that will execute our
php_shell.sh
.# cat > wrapper.c <<CONTENT
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int
main (int argc, char *argv[])
{
setuid (0);
/* WARNING: Only use an absolute path to the script to execute,
* a malicious user might fool the binary and execute
* arbitary commands if not.
* */
system ("/bin/sh /path/to/php_shell.sh");
return 0;
}
CONTENT
4) Compile and set proper permissions, including the suid bit (saying that it should run with root privileges):
# gcc wrapper.c -o php_root
# chown root php_root
# chmod u=rwx,go=xr,+s php_root
php_root
will now run with root permissions, and execute the commands specified in php_root.sh
.
If you don't need to the option to easily change what commands that will be executed I'd recommend you to write the commands directly in
wrapper.c
under step 4. Then you don't need to have a binary executing a external script executing the commands in question.
In
source https://stackoverflow.com/a/8532448
wrapper.c
, use system ("your shell command here");
to specify what commands you'd like to executesource https://stackoverflow.com/a/8532448
14 March 2018
Install specific Ubuntu package without recommended packages
apt-get --no-install-recommends install asciidoc -y
Subscribe to:
Posts (Atom)