Overview of xerox_printers.inc

Automatic Includes

These files are automatically included by the library.

Public Variable Summary

Public variables are intended to be accessed by the code that imports this library.

Name Summary
cookie
cookie
last_pass
last_user

Public Function Summary

Public functions are intended to be called by the code that imports this library.

Name Summary
build_xerox_cpe
check_xerox_default_login
error_exit
set_cookie
xerox_default_logins
xerox_login_details

Public Variable Details

top
top

last_pass

top

last_user

top

Public Function Details

build_xerox_cpe

Named Parameters

model

Code

function build_xerox_cpe(model) {

  cpe = 'cpe:/h';

  if("WorkCentre" >< model) {

    model = tolower(model);
    m = split(model, sep:" ", keep:FALSE);

    if(isnull(m[1])) {
     return cpe + ':xerox:workcentre';
    } else {
      return cpe + ':xerox:workcentre_' + m[1];
    }

  }

  else if("Phaser" >< model) {

    model = tolower(model);
    m = split(model, sep:" ", keep:FALSE);

    if(isnull(m[1])) {
      return cpe + ':fuji_xerox:phaser';
    } else {
      return cpe + ':fuji_xerox:phaser_' + m[1];
    }  

  } 

  else if("ColorQube" >< model) {

    model = tolower(model);
    m = split(model, sep:" ", keep:FALSE);

    if(isnull(m[1])) {
      return cpe + ':xerox:colorqube';
    } else {
      return cpe + ':xerox:colorqube_' + m[1];
    }

  }

  return 'cpe:/h:xerox';

}

function set_cookie(url) {

		
top

check_xerox_default_login

Named Parameters

model

Code

function check_xerox_default_login(model) {
 
  local_var userame, password, xerox;
  global_var last_user, last_pass;

  xerox = xerox_login_details(model:model);
  if(!xerox) return FALSE;

  logins = xerox_default_logins();

  foreach login (logins) {

    user_pass = split(login,sep:":", keep:FALSE);
    username = user_pass[0];
    password = user_pass[1];

    login_data = xerox['login_data'];
    if(login_data) {
      login_data = str_replace(string:login_data, find:"%%%USERNAME%%%", replace:username);
      login_data = str_replace(string:login_data, find:"%%%PASSWORD%%%", replace:password);
    }

    len = strlen(login_data);

    if(xerox['req_type'] == "POST") {

      if(xerox['login_url_success']) {
        req = string(xerox['req_type_success'], " ", xerox['login_url_success'], " HTTP/1.1\r\n",
                     "Host: ", get_host_name(),"\r\n",
                     "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Firefox/17.0\r\n\r\n");
 
        buf = http_send_recv(port:port, data:req, bodyonly:FALSE);
        error_exit(buf:buf);

        if(eregmatch(pattern:xerox['login_success'], string:buf)) {
          return 2; # setup without auth
        }
 
      }

      req = string("POST " , xerox['login_url'], " HTTP/1.1\r\n",
                   "Host: ", get_host_name(),"\r\n",
                   "DNT: 1\r\n",
                   "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Firefox/17.0\r\n",
                   "Content-Type: application/x-www-form-urlencoded\r\n",
                   "Content-Length: ",len,"\r\n");

      if(cookie) req +=  string("Cookie: ",cookie,"\r\n");

      req += string("\r\n",login_data,"\r\n");

    } 

    else if(xerox['req_type'] == "GET") {

      if(xerox['req_auth'] == "BASIC") {

        userpass = username + ':' + password;
        userpass64 = base64(str:userpass);

        req = string("GET ", xerox['login_url']," HTTP/1.1\r\n",
                     "Host: ", get_host_name(),"\r\n");

        c_buf = http_keepalive_send_recv(port:port, data:req + '\r\n', bodyonly:FALSE);
        error_exit(buf:c_buf);

        if("HTTP/1.1 401" >!< c_buf && "HTTP/1.1 302" >!< c_buf) return 2; # setup without auth

        if(cookie) req += string("Cookie: ",cookie,"\r\n");

        req += string("Authorization: Basic ",userpass64,"\r\n\r\n");

      }

    } else {
      return FALSE;
    }

    buf = http_send_recv(port:port, data:req, bodyonly:FALSE); # login

    if(xerox['http_status'] >< buf) {

      if(xerox['login_url_success']) {
        req = string(xerox['req_type_success'], " ", xerox['login_url_success'], " HTTP/1.1\r\n",
                    "Host: ", get_host_name(),"\r\n");

        if(cookie) req +=  string("Cookie: ",cookie,"\r\n");

        req += string("User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Firefox/17.0\r\n\r\n");

        buf = http_send_recv(port:port, data:req, bodyonly:FALSE);
        error_exit(buf:buf);
      }  

      if(eregmatch(pattern:xerox['login_success'], string:buf)) { 
        last_user = username;
        last_pass = password;
        return 1;
      }

    }  
  }

  return FALSE;  

}  

function xerox_login_details(model) {

		
top

error_exit

Named Parameters

buf

Code

function error_exit(buf) {

  if(!buf || ereg(pattern:"HTTP/1.(0|1) (404|500)", string: buf))exit(0);

  return TRUE;

}


		
top

Named Parameters

url

Code

function set_cookie(url) {

  global_var cookie;

  req = http_get(item:url, port:port);
  buf = http_send_recv(port:port, data:req, bodyonly:FALSE);

  if("Set-Cookie:" >!< buf) return FALSE;

  co = eregmatch(pattern:"Set-Cookie: ([^; ]+)", string:buf);
  if(!isnull(co[1])) {
    cookie = co[1];
    return TRUE;
  }  

  return FALSE;

}  

function error_exit(buf) {

		
top

xerox_default_logins

Named Parameters

Code

function xerox_default_logins() {

  return make_list("admin:1111",
                   "11111:x-admin",
                   "admin:x-admin",
                   "admin:sysadmin",
                   "admin:admin",
                   "Administrator:administ",
                   "Administrator:Fiery.1",
                   "admin:2222",
                   "HTTP:admin",
                   "savelogs:crash");
}  

function check_xerox_default_login(model) {

		
top

xerox_login_details

Named Parameters

model

Code

function xerox_login_details(model) {

  global_var cookie;

  xerox = make_array();

  if(model == "WorkCentre 5030"   ||
     model == "WorkCentre 5135"   ||
     model == "WorkCentre 5150"   ||
     model == "WorkCentre 5632"   ||
     model == "WorkCentre 5638"   ||
     model == "WorkCentre 5655"   ||
     model == "WorkCentre 5745"   ||
     model == "WorkCentre 5755"   ||
     model == "WorkCentre 5765"   ||
     model == "WorkCentre 5775"   ||
     model == "WorkCentre 6400S"  || 
     model == "WorkCentre 6400X"  ||
     model == "WorkCentre 6400XF" ||
     model == "WorkCentre 7525"   ||
     model == "WorkCentre 7530"   ||
     model == "WorkCentre 7535"   ||
     model == "WorkCentre 7545"   ||
     model == "WorkCentre 7556"   ||
     model == "WorkCentre 7765"   ||
     model == "ColorQube 9301"    ||
     model == "ColorQube 9302"    ||
     model == "ColorQube 9303"    ||
     model == "Phaser 6700DT") {

    if(!cookie) set_cookie(url:'/header.php');

    xerox['req_type'] = "POST";
    xerox['login_url'] = '/userpost/xerox.set';
    xerox['login_data'] = '_fun_function=HTTP_Authenticate_fn&NextPage=%2Fproperties%2Fauthentication%2FluidLogin.php&webUsername=%%%USERNAME%%%&webPassword=%%%PASSWORD%%%&frmaltDomain=default';

    xerox['req_type_success'] = "GET";
    xerox['login_url_success'] = '/header.php'; 

    xerox['http_status'] = 'HTTP/1.1 200';
    xerox['login_success'] = '>Logout</a>'; 

    return xerox;

  } 

  else if(model == "WorkCentre 5225"    ||
          model == "WorkCentre 5225A"   ||
          model == "WorkCentre 5325"    ||
          model == "WorkCentre 7120"    ||
          model == "WorkCentre 7232"    ||
          model == "WorkCentre 7328"    ||
          model == "WorkCentre 7345"    ||
          model == "WorkCentre 7346"    ||
          model == "WorkCentre 7425"    ||
          model == "WorkCentre 7428"    ||
          model == "ApeosPort-IV C3370" ||
          model == "ApeosPort-IV C4470" ||
          model == "WorkCentre 7435") {

    xerox['req_type'] = "GET";
    xerox['login_url'] = '/prscauthconf.htm';
    xerox['req_auth'] = "BASIC";

    xerox['http_status'] = 'HTTP/1.1 200';
    xerox['login_success'] = 'HTTP/1.1 200';

    return xerox;

  }

  else if(model == "WorkCentre 6505DN" ||
          model == "Phaser 6128MFP-N") {

    xerox['req_type'] = "GET";
    xerox['login_url'] = '/srvcset/emlusrlst.htm';
    xerox['req_auth'] = "BASIC";

    xerox['http_status'] = 'HTTP/1.1 200';
    xerox['login_success'] = '>Email Address Book';

    return xerox;

  }  

  else if(model == "WorkCentre M20i"  ||
          model == "WorkCentre PE120" || 
          model == "WorkCentre 4118"  ||
          model == "WorkCentre 4150"  ||
          model == "WorkCentre 4250") {

    xerox['req_type'] = "GET";
    xerox['login_url'] = '/reloadMaintenance.dhtml';
    xerox['req_auth'] = "BASIC";

    xerox['http_status'] = 'HTTP/1.1 200';
    xerox['login_success'] = 'this.location = "(/maintenance/index.dhtml|/properties/maintenance/fwupgrade.dhtml)"';

    return xerox;

  }  

  else if (model == "WorkCentre 7132" ||
           model == "WorkCentre 7235" ||
           model == "WorkCentre 7242" ||
           model == "WorkCentre 7245") {

    xerox['req_type'] = "GET";
    xerox['login_url'] = '/spadm.htm';
    xerox['req_auth'] = "BASIC";

    xerox['http_status'] = 'HTTP/1.1 200';
    xerox['login_success'] = '<TITLE>Internet Services Settings';

    return xerox;

  } 

  else if (model == "generic_basic_auth") {

    xerox['req_type'] = "GET";
    xerox['login_url'] = '/';
    xerox['req_auth'] = "BASIC";

    xerox['http_status'] = 'HTTP/1.1 200';
    xerox['login_success'] = 'HTTP/1.1 200';

    return xerox;

  }  

  else if (model == "WORKCENTRE PRO") {

    xerox['req_type'] = "GET";
    xerox['login_url'] = '/properties/upgrade/m_software.dhtml';
    xerox['req_auth'] = "BASIC";

    xerox['http_status'] = 'HTTP/1.1 200';
    xerox['login_success'] = 'HTTP/1.1 200';

    return xerox;

  }

  else if (model == "WorkCentre 3210" ||
           model == "WorkCentre 3220" ||
           model == "WorkCentre 3550" ||
           model == "Phaser 3435") {

    xerox['req_type'] = "GET";
    xerox['login_url'] = '/properties/securitysettings.html';
    xerox['req_auth'] = "BASIC";

    xerox['http_status'] = 'HTTP/1.1 200';
    xerox['login_success'] = '<title> Security Settings';

    return xerox;

  } 

  else if (model == "ColorQube 8570") {

    xerox['req_type'] = "GET";
    xerox['login_url'] = '/securitysettings.html';
    xerox['req_auth'] = "BASIC";

    xerox['http_status'] = 'HTTP/1.1 200';
    xerox['login_success'] = 'Administrative Security Settings';

    return xerox;

  }

  else if(model == "Phaser 7760"   ||
          model == "Phaser 7760DN" ||
          model == "Phaser 7760GX") {

    xerox['req_type'] = "GET";
    xerox['login_url'] = '/deletesecurejobs.html';
    xerox['req_auth'] = "BASIC";

    xerox['http_status'] = 'HTTP/1.1 200';
    xerox['login_success'] = '<b>Delete All Secure Jobs</b>';

    return xerox;

  }  

  exit(0); # we don't know this printer

}

function build_xerox_cpe(model) {

		
top