Exemple #1
0
function generate($key)
{
    echo "    input key: ";
    dumpkey($key);
    echo " permuted key: ";
    $permuted = permute($key);
    dumpkey($permuted);
    echo "   CRC'ed key: ";
    $crc = crc($permuted);
    dumpkey($crc);
    return $crc;
}
Exemple #2
0
function get_binary_packet($fsock)
{
    $temp = unpack('Nlen', fread($fsock, 4));
    $padding_length = 8 - ($temp['len'] & 7);
    $raw = fread($fsock, $temp['len'] + $padding_length);
    $padding = substr($raw, 0, $padding_length);
    $type = $raw[$padding_length];
    $data = substr($raw, $padding_length + 1, -4);
    $temp = unpack('Ncrc', substr($raw, -4));
    if ($temp['crc'] != crc($padding . $type . $data)) {
        die('Bad CRC in packet from server');
    }
    return array('type' => ord($type), 'data' => $data);
}
Exemple #3
0
<?php

$page_title = 'Установка прав доступа';
$destination = get_request_variable('destination', '');
$destination = preg_replace('/[\\/]{2,}/', '/', $destination);
$enabled_file_roles = get_request_variable('enabled_file_roles', array());
$save = get_request_variable('save', '');
$_REQUEST['callback'] = get_request_variable('callback', '');
$destination_win1251 = mb_convert_encoding($destination, 'windows-1251', 'utf-8');
$destination_win1251 = SITE_PROJECT_FILE_ROOT . str_replace('..', '', $destination_win1251);
$file = new file();
if (!$file->LoadByCrc(crc($destination))) {
    if (file_exists($destination_win1251) && is_file($destination_win1251)) {
        $file->name = basename($destination);
        $file->path = dirname($destination);
        $file->Save();
    } else {
        $errors[] = 'Файл не найден';
    }
}
$errors = array();
if ($save) {
    if (!$enabled_file_roles) {
        $errors[] = 'Укажите доступные роли';
    }
    if (!$errors) {
        $db = db_class::get_instance();
        $db->begin();
        $file->DeleteFileRoles();
        reset($enabled_file_roles);
        $file_role = new file_role();
Exemple #4
0
<?php

$page_title = 'Перенос каталогов/файлов';
$source = preg_replace('/[\\/]{2,}/', '/', get_request_variable('source', ''));
$source_win1251 = mb_convert_encoding($source, 'windows-1251', 'utf-8');
$destination = preg_replace('/[\\/]{2,}/', '/', get_request_variable('destination', '') . '/');
$destination_win1251 = mb_convert_encoding($destination, 'windows-1251', 'utf-8');
$errors = array();
if (file_exists(SITE_PROJECT_FILE_ROOT . $source_win1251)) {
    $file = new file();
    if (is_file(SITE_PROJECT_FILE_ROOT . $source_win1251)) {
        if ($file->LoadByCrc(crc($source))) {
            $file->path = $destination;
            $file->Save();
        }
    } else {
        $file->MoveSource($source, $destination);
    }
    smart_move($source_win1251, $destination_win1251, true);
}
include SITE_FILE_ROOT . 'template/simple_header.php';
include SITE_FILE_ROOT . 'template/' . $STORAGE['module'] . '/' . $STORAGE['action'] . '.php';
include SITE_FILE_ROOT . 'template/simple_footer.php';
Exemple #5
0
}
if ($counter_session > 255) {
    $counter_session = 0;
}
if ($timer > 16777215) {
    $timer = 0;
}
if ($random > 65535) {
    $random = rand(0, 65535);
}
// Pack the yubikey data
$crbin = pack('H*', $secretID);
$crbin .= chr($counter % 256);
$crbin .= chr($counter / 256);
$crbin .= chr($timer % 65536);
$crbin .= chr($timer / 256);
$crbin .= chr($timer / 65536);
$crbin .= chr($counter_session);
$crbin .= chr($random % 256);
$crbin .= chr($random / 256);
$crc = crc($crbin);
$crbin .= chr($crc % 256);
$crbin .= chr($crc / 256);
require_once 'AES128.php';
$aes = new AES128();
$key = $aes->makeKey(pack('H*', $secret_aes_key));
// Encrypt the data and modhex encode it
$coded = $aes->blockEncrypt($crbin, $key);
$token = $publicID . modhex_encode($coded);
function modhex_encode($mstring)
{
function par($data)
{
    $split = str_split(strtolower(bin2hex(strval(get_signed_int(crc($data))))), 10);
    $return = $split[0];
    return $return;
}