다른 사이트(로컬)의 파일을 클라이언트가 설치할 수 있게 해주는 php 코드 예제 > 코딩 스토리

다른 사이트(로컬)의 파일을 클라이언트가 설치할 수 있게 해주는 php 코드 예제

페이지 정보

작성자 이름으로 검색 (192.♡.0.1) 작성일 23-07-20 23:02 조회 9,119 댓글 1

본문

[code]

function downloadRemoteFile($url, $filename) {

    $userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36';

    $referer = 'https://www.google.com/';


    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);

    curl_setopt($ch, CURLOPT_REFERER, $referer);

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    $data = curl_exec($ch);


    if (curl_errno($ch)) {

        curl_close($ch);

        return false;

    }


    $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

    curl_close($ch);


    if ($status_code == 200) {

        header('Content-Description: File Transfer');

        header('Content-Type: application/octet-stream');

        header('Content-Disposition: attachment; filename="' . $filename . '"');

        header('Content-Transfer-Encoding: binary');

        header('Expires: 0');

        header('Content-Length: ' . strlen($data));


        echo $data;

        return true;

    } else {

        return false;

    }

}


// 다운로드할 PHP 파일의 URL

$phpFileUrl = 'http://example.com/path/to/remote_php_file.php';


// 클라이언트가 다운로드할 때 사용되는 파일명

$clientFileName = 'downloaded_file.php';


if (downloadRemoteFile($phpFileUrl, $clientFileName)) {

    echo '파일 다운로드 성공: ' . $clientFileName;

} else {

    echo '파일 다운로드 실패';

}

?>

[/code]
사이트의 접속 또는 다운로드 차단을 회피할 수 있고, 사진 동영상 html, js, css 파일 정도를 다운로드 할 수 있을 것으로 예상됨
좋아요108 이 글을 좋아요하셨습니다
url 복사 카카오톡 공유 라인 공유 페이스북 공유 트위터 공유
지역-로컬
Powered by AI
<\/p>

function downloadRemoteFile($url, $filename) {<\/p>

    $userAgent = 'Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/91.0.4472.124 Safari\/537.36';<\/p>

    $referer = 'https:\/\/www.google.com\/';<\/p>


<\/p>

    $ch = curl_init();<\/p>

    curl_setopt($ch, CURLOPT_URL, $url);<\/p>

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<\/p>

    curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);<\/p>

    curl_setopt($ch, CURLOPT_REFERER, $referer);<\/p>

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);<\/p>

    $data = curl_exec($ch);<\/p>


<\/p>

    if (curl_errno($ch)) {<\/p>

        curl_close($ch);<\/p>

        return false;<\/p>

    }<\/p>


<\/p>

    $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);<\/p>

    curl_close($ch);<\/p>


<\/p>

    if ($status_code == 200) {<\/p>

        header('Content-Description: File Transfer');<\/p>

        header('Content-Type: application\/octet-stream');<\/p>

        header('Content-Disposition: attachment; filename=\"' . $filename . '\"');<\/p>

        header('Content-Transfer-Encoding: binary');<\/p>

        header('Expires: 0');<\/p>

        header('Content-Length: ' . strlen($data));<\/p>


<\/p>

        echo $data;<\/p>

        return true;<\/p>

    } else {<\/p>

        return false;<\/p>

    }<\/p>

}<\/p>


<\/p>

\/\/ \ub2e4\uc6b4\ub85c\ub4dc\ud560 PHP \ud30c\uc77c\uc758 URL<\/p>

$phpFileUrl = 'http:\/\/example.com\/path\/to\/remote_php_file.php';<\/p>


<\/p>

\/\/ \ud074\ub77c\uc774\uc5b8\ud2b8\uac00 \ub2e4\uc6b4\ub85c\ub4dc\ud560 \ub54c \uc0ac\uc6a9\ub418\ub294 \ud30c\uc77c\uba85<\/p>

$clientFileName = 'downloaded_file.php';<\/p>


<\/p>

if (downloadRemoteFile($phpFileUrl, $clientFileName)) {<\/p>

    echo '\ud30c\uc77c \ub2e4\uc6b4\ub85c\ub4dc \uc131\uacf5: ' . $clientFileName;<\/p>

} else {<\/p>

    echo '\ud30c\uc77c \ub2e4\uc6b4\ub85c\ub4dc \uc2e4\ud328';<\/p>

}<\/p>

?><\/p>

[\/code]<\/div>
\uc0ac\uc774\ud2b8\uc758 \uc811\uc18d \ub610\ub294 \ub2e4\uc6b4\ub85c\ub4dc \ucc28\ub2e8\uc744 \ud68c\ud53c\ud560 \uc218 \uc788\uace0, \uc0ac\uc9c4 \ub3d9\uc601\uc0c1 html, js, css \ud30c\uc77c \uc815\ub3c4\ub97c \ub2e4\uc6b4\ub85c\ub4dc \ud560 \uc218 \uc788\uc744 \uac83\uc73c\ub85c \uc608\uc0c1\ub428<\/div>", current_is_spam: 0, current_confidence: 50 }; }DSc_patronus+학습 자동화 -->

2kat님의 댓글

no_profile 2kat쪽지보내기 자기소개 아이디로 검색 전체게시물 아이피 (220.♡.000.000) 작성일

좋네요

😶
❤️
😂
😅
😮
😡
🥵
  • RSS
  • _  글쓰기 글쓰기
전체 303건
게시물 검색

접속자집계

오늘
2,240
어제
4,635
최대
42,418
전체
1,132,769