[ / / / / / / / / / / / / / ] [ dir / agatha2 / choroy / coz / doomer / fast / leo / pawsru / revel3 ][Options][ watchlist ]

/tech/ - Technology

You can now write text to your AI-generated image at https://aiproto.com It is currently free to use for Proto members.
Email
Comment *
Verification *
File
Select/drop/paste files here
Password (Randomized for file and post deletion; you may also set your own.)
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Expand all images

File (hide): 535e21a9fe54c88⋯.png (140.24 KB, 1156x666, 578:333, praisekek.png) (h) (u)

File (hide): c1aa0ec31be841f⋯.jpg (80.67 KB, 1600x900, 16:9, kekflag.jpg) (h) (u)

[–]

 No.1064567[Watch Thread][Show All Posts]

I've been messing around with some python and doing reverse tcp shells and shit like that. I won't post that code because shit's not done. But today in the midst of other autism I came up with some things you might find useful for customizing a shell.

Firstly I'm going go over how to make a banner or ascii art. You do it manually and cool if you are into that. But here's a cheater way to do that with python. You can scroll down and copy the script and paste it to a file and save it as something.py https://www.geeksforgeeks.org/converting-image-ascii-image-python/

Then grab an image from your collection of dank memes. Line drawings work the best. I was going to figure out how to get a grid of pixels from an image and then use colorama and convert it to color blocks in terminal which would be kinda cool but not genuine ascii art.

Open your image in GIMP >> image >> scale image. Then scale to pixel size that roughly matches the rows and coloumns of your terminal Window.

I did this the Kekistan flag just to see what I could come up with. Came out alright.

python imageconversion.py --file /kekflag2.png --scale .5 --out kek.txt --cols 128 --morelevels

You will have to fuck around with this a bit to get the image scale in characters to display right in terminal and look decent.

Once you get the command line syntax you can cat the text file and see what it looks like in terminal. It probably won't look like you want it to at first keep trying different things. The scale option can be floating point so try like .5 .7 if the image takes up to many columns vertically to display correctly.

Once you have the skeleton of what you want. Open up with text editor and manually edit and tweak things to make it look just right.

Have fun with this.

 No.1064571>>1064848

If you want a more simple banner you can use something like pyfiglet as shown in this tutorial https://www.devdungeon.com/content/create-ascii-art-text-banners-python

Something else I came up with today while I was fucking around with writing a reverse TCP shell and server. I was thinking it could be fun to just customize the command prompt and add in some of my own commands. I really haven't done much with this as I have some other projects take priority.


#!/usr/bin/python3
import threading
import time
from queue import Queue
import socket
import sys
import os
import subprocess


def Pepe():
while 1:
print('Pepe>', end="")
cmd = input()
com=cmd.strip()
if com == "quit":
break
if com[:2] == "cd":
os.system(com)
if len(com) > 0:
cmd = subprocess.Popen(com[:], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
output_bytes = cmd.stdout.read() + cmd.stderr.read()
output_str = str(output_bytes, "utf-8")
print(output_str, end="")
Pepe()

You can add in some custom commands and scripts but this is the basics of it. If you have something to add please do.

I was also looking for a way to easily change font size in terminal but that doesn't appear to be supported in any language the easiest example I found with with C/C++ on Windows and I don't have time for Windows.

Enjoy /tech/


 No.1064831

This is a quality post. Thank you. Can you script this using image magic to keep it all in terminal?


 No.1064848>>1065326 >>1065382

>>1064571

if com[:2] == "cd":
os.system(com)

this won't work. use os.chdir


 No.1065326

>>1064848

I'll definitely have to mess around with this some more. I wasn't sure how get previous working directory so I could cd - but I think I can save each pwd a variable then move it to a second variable and write pwd to the first with each cd command. Then there was the issue of getting user's home directory. I really wasn't sure how to do it but I know when when used the subprocess method it crashed. You just gave me an idea for something too. Creating a directory history just like you have a command line history.

I need to figure out a better way to parse this and read through shit. Everything seems to work except cd.

I think I need to go over com and com2 and figure out another way to write this thing.

Thanks for pointing this out.


 No.1065382

>>1064848

Thanks g. I fixed it! But fuckall that was more logic to figure out than I thought it would be and now it seems like no matter where I put the print statment for the curser and print('Pepe>', end="") it will print nothing but then once in a while it will print a ton of them. Not sure if it's end that's fucking this up of if it's my enterpreter. But cd, cd -, cd <path> work the way they are supposed to.

#!/usr/bin/python3
import threading
import time
from queue import Queue
import socket
import sys
import os
import subprocess

def Pepe():
while 1:
current_dir = os.getcwd()
cmd = sys.stdin.readline()
com=cmd.strip()
if com == "quit":
break
if com == "cd":
old_dir=current_dir
os.chdir("/")
current_dir = os.getcwd()
new_dir = current_dir
elif com == "cd -":
current_dir = os.getcwd()
os.chdir(old_dir)
old_dir = current_dir
elif com.startswith("cd") and com != "cd" and com != "cd -":
old_dir=current_dir
c, d = com.split(" ")
os.chdir(d)
current_dir = os.getcwd()
last_dir = current_dir
else:
cmd = subprocess.Popen(com[:], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
output_bytes = cmd.stdout.read() + cmd.stderr.read()
output_str = str(output_bytes, "utf-8")
print(output_str, end='')

Pepe()


 No.1065390>>1065401

libcaca


 No.1065401

>>1065390

That is really cool.

Are there any open applications available or just the library? I can't really seem to find any solid tutorials. Finding a lot of cool examples. The autism level on this is >9k

https://www.youtube.com/watch?v=wNmukHKUFTc




[Return][Go to top][Catalog][Screencap][Nerve Center][Cancer][Update] ( Scroll to new posts) ( Auto) 5
7 replies | 0 images | Page ???
[Post a Reply]
[ / / / / / / / / / / / / / ] [ dir / agatha2 / choroy / coz / doomer / fast / leo / pawsru / revel3 ][ watchlist ]