Sunday, January 3, 2021

download VIDEO STREAMING tool

 There are many different type of download video streaming tool.  I believe many people used it before, but I still wants to share it to you. 


Before introduce this tool, I would like to teach how to capture video streaming file from browse. I believe from people would know that when I mention about browser you would reflect it to devtool, well that's right. I am using the devtool to teach how to capture the stream, which is pretty good tool to used.


I like to used YouTube as an example, please notice that youtube steaming split the audio and video stream into two part, the file for video will be webm, and audio would be weba. 

Today many web development's security are improvement, some site would not be easy to capture. 

Procedure: 

1. Lauch your site to youtube and click any video you like

2. left click and presss "inspect"

3. go to "network" and go to xhR 

you can see there is a playlist, click on it, you will see the url requst, and content type to make sure it's video type. Note that each pair will have one video one audio stream. 

4. select the url and right click to direct to the page and download it. (downlaod both audio and video)




The next thing I wants to intoduce the tool, whic is FFMPEG, this is an oepnsource tool, but it's not GUI, you need to type this command. This tool is to convert the file to any format you like. If you have a mp4 file, and can also convert to mp3. You don't have to used any other tool. 

Got to this page to download it: https://ffmpeg.org/download.html

You can click on documentation to understand more command. 

I will only teach you 2 command: 

1. convert single file: ffmpeg -i filename xxx.[mp3 or mp4 or any file you want)

ffmpeg -i video.mp4 mysong.mp3

2. convert audio and video and merge into one file. 

ffmpeg -i video.webm -i audio.weba -c:v copy -c:a aac myvideo.mp4

After you know the command, and download ffmpeg tool, put the two file you download from youtube and copy it into the same directory and used the second command will be able to see the video. 

But there is another tool you can use it's much easier, called youtube-dl, command is youtube-dl "youtube url" that's it, you don't need to open devtool. 


Thursday, December 17, 2020

scanning port (NMAP)

 

TCP:

nmap -v -sT -T2 -Pn -p T:5060,111,65431,44318,4159,80,443,53 IPv4-Address

nmap -v -sT -T2 -Pn -p T:52224,705,111,51413,37915,4159,22,23 -6 IPv6-Address

UDP:

nmap -v -sU -T2 -Pn -p U:1293,111,161,162,3000,5060,546,53  IPv4-Address

nmap -v -sU -T2 -Pn -p U:1293,111,2427,161,162,3000,546 -6  IPv6-Address


hping IP Flood attack to DUT


 1. Connect a LAN PC to DUT via ethernet. Do " ping  8.8.8.8 -t" and access websites, can success.

2. Use hping3 command " hping3 -S -P -U --flood -V --rand-source DUT-IP" ( DUT's  IP) to attack DUT WAN IP.

3. After a while, no more than 1 minutes, LAN PC can not ping successfully, and can not access internet.

4. Use hping3 command "hping3 -1 --flood -V target" generate icmp flood to attack DUT WAN IP.

5. After a while, LAN PC can not ping successfully, and can not access internet.

Monday, June 22, 2020

pyhton error Anaconda3

if you run python see this problem related to Anaconda3
Anaconda3\lib\site-packages\numpy\__init__.py:140: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service

Solution:
go to environment setting and add this in it: C:\Users\username\Anaconda3\Library\bin

Sunday, June 7, 2020

python with database



import sqlite3
conn = sqlite3.connect('D:\\hskio_python.db')
try:
    info = []
    cur = conn.cursor()
    rows = cur.execute('select * from person')
    for row in rows:
        id = row[0]
        hei ght = row[2]
        weight = row[3]
        bmi = round(weight/height**2, 2)
        print(id, height, weight, bmi)
        info.append([bmi, id])
    for data in info:
        cur.execute('update person set bmi=%d where id=%d' % (data[0], data[1]))
    conn.commit()
    
finally:
    conn.close()


beautifulsoup example

 beautifulsoup example 

Find and Findall Parameter:


findAll(tag, attributes, recursive, text, limit, keywords) find(tag, attributes, recursive, text, keywords)

Find Parameter: 
 beautifulsoup example  Find h1 tag
import requests
from bs4 import BeautifulSoup
resp=requests.get("https://code-gym.github.io/spider_demo/")
soup=BeautifulSoup(resp.text, 'html5lib')
print(soup.find('h1'))

beautifulsoup print with tag and without

With tag 
print(soup.find('h1'))

Without tag 
print(soup.h1)

Findall parameter: 


for h3 in soup.find_all('h3'): print(h3)

Find class name
for title in soup.find_all('h3','post-title'): print(title)


beautifulsoup crawl ptt sock

去ptt 股票爬文章


import requests
from bs4 import BeautifulSoup
import time
today = time.strftime('%m/%d').lstrip('0')

def ptt(url):
    resp = requests.get(url)
    if resp.status_code != 200:
        print('URL發生錯誤:' + url)
        return
    soup = BeautifulSoup(resp.text, 'html5lib')
    paging = soup.find('div', 'btn-group btn-group-paging').find_all('a')[1]['href']

    articles = []
    rents = soup.find_all('div', 'r-ent')

    for rent in rents:
        title = rent.find('div', 'title').text.strip()
        count = rent.find('div', 'nrec').text.strip()
        date = rent.find('div', 'meta').find('div', 'date').text.strip()
        article = '%s %s:%s' % (date, count, title)

        try:
            if today == date and int(count) > 10:
                articles.append(article)
        except:
            if today == date and count == '爆':
                articles.append(article)
    if len(articles) != 0:
        for article in articles:
            print(article)
        ptt('https://www.ptt.cc' + paging)
    else:
        return

ptt('https://www.ptt.cc/bbs/Stock/index.html')