<commit_before>__author__ = 'jiasir'

import os
import subprocess
import socket

try:
    os.system(
        'c:\\windows\\system32\\inetsrv\\appcmd.exe set config -section:system.webServer/httpProtocol /-"customHeaders.[name=\'X-Powered-By\']"')
except:
    pass


def add_header(site_name='Default Web Site', header_name='X-Served-By', app_name='www', ip='172.16.58.3'):
    """
    add http response header to iis
    :param site_name: iis web site
    :param header_name: which header to be added
    :param app_name: application name
    :param ip: local ip
    :return: None
    """
    os.system(
        'c:\\windows\\system32\\inetsrv\\appcmd.exe set config "{site_name}" -section:system.webServer/httpProtocol /+"customHeaders.[name=\'{header_name}\',value=\'{app_name}>>{ip}\']"'.format(
            site_name=site_name, header_name=header_name, app_name=app_name, ip=ip))


def get_sites():
    """
    get all sites
    :return: a list of sites
    """
    output = subprocess.Popen(['c:\\windows\\system32\\inetsrv\\appcmd.exe', 'list', 'site'],
                              stdout=subprocess.PIPE).communicate()[0]

    sites = []
    for line in output.split(os.linesep):
        if line != '':
            site = line.split('"')[1]
            sites.append(site)
    return sites


def get_ip():
    """
    get the host ip
    :return: string of ip
    """
    hostname = socket.gethostname()
    ip = socket.gethostbyname(hostname)
    return ip


def main():
    sites = get_sites()
    for s in sites:
        add_header(site_name=s, app_name=s, ip=get_ip())


if __name__ == '__main__':
    main()<commit_msg>Update remote X-Powered-By<commit_after>__author__ = 'jiasir'

import os
import subprocess
import socket


def add_header(site_name='Default Web Site', header_name='X-Served-By', app_name='www', ip='1.2.3.4'):
    """
    add http response header to iis
    :param site_name: iis web site
    :param header_name: which header to be added
    :param app_name: application name
    :param ip: local ip
    :return: None
    """
    os.system(
        'c:\\windows\\system32\\inetsrv\\appcmd.exe set config "{site_name}" -section:system.webServer/httpProtocol /+"customHeaders.[name=\'{header_name}\',value=\'{app_name}>>{ip}\']"'.format(
            site_name=site_name, header_name=header_name, app_name=app_name, ip=ip))


def get_sites():
    """
    get all sites
    :return: a list of sites
    """
    output = subprocess.Popen(['c:\\windows\\system32\\inetsrv\\appcmd.exe', 'list', 'site'],
                              stdout=subprocess.PIPE).communicate()[0]

    sites = []
    for line in output.split(os.linesep):
        if line != '':
            site = line.split('"')[1]
            sites.append(site)
    return sites


def get_ip():
    """
    get the host ip
    :return: string of ip
    """
    hostname = socket.gethostname()
    ip = socket.gethostbyname(hostname)
    return ip


def main():
    try:
        os.system(
            'c:\\windows\\system32\\inetsrv\\appcmd.exe set config -section:system.webServer/httpProtocol /-"customHeaders.[name=\'X-Powered-By\']"')
    except:
        pass

    sites = get_sites()
    for s in sites:
        add_header(site_name=s, app_name=s, ip=get_ip())


if __name__ == '__main__':
    main()
{'fraction_non_alphanumeric': 0.15183723048891587, 'fraction_numerical': 0.00850288490737929, 'mean_word_length': 2.7474402730375425, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7457901', 'n_tokens_mistral': 1132, 'n_tokens_neox': 1102, 'n_words': 243}